From fc6fd89d82dd01482f771fe5ad9161a7eba6d892 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lippi?= Date: Tue, 18 Jun 2024 15:48:03 -0300 Subject: [PATCH 1/2] #86dtu8yuk - Include how to use NEP17Contract to Calling contracts documentation --- docs/source/calling-smart-contracts.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/source/calling-smart-contracts.md b/docs/source/calling-smart-contracts.md index a86444ac..bcb89021 100644 --- a/docs/source/calling-smart-contracts.md +++ b/docs/source/calling-smart-contracts.md @@ -85,6 +85,22 @@ def calling_other_contract() -> str: return neo_symbol ``` +### Calling NEP-17 Contracts +In addition, Neo3-Boa has an interface for contracts that adhere to the NEP-17 standard. +```python +# calling_nep17_contract.py +from boa3.sc.compiletime import public +from boa3.sc.contracts import ContractManagement +from boa3.sc.types import Nep17Contract + + +@public +def calling_other_contract(my_contract_hash: str) -> str: + nep_17_contract: Nep17Contract = ContractManagement.get_contract(my_contract_hash) + return nep_17_contract.symbol() +``` +> Note: The compiler cannot validate if the provided contract hash corresponds to a NEP-17 contract. If the corresponding smart contract does not implement a required NEP-17 method and such method is called, it will cause a runtime error. + ### Automate with CPM Instead of manually writing the smart contract interface, you can use [CPM](https://github.com/CityOfZion/cpm/tree/master#readme) to generate it automatically. After installing Neo3-Boa, you can install CPM by typing `install_cpm` on CLI (without the From 845aa703bab3bb15467ce062fa3bc4ee002834ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lippi?= Date: Wed, 19 Jun 2024 02:26:31 -0300 Subject: [PATCH 2/2] #86dtu8yuk - Include how to use NEP17Contract to Calling contracts documentation --- docs/source/calling-smart-contracts.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/calling-smart-contracts.md b/docs/source/calling-smart-contracts.md index bcb89021..7ed88b68 100644 --- a/docs/source/calling-smart-contracts.md +++ b/docs/source/calling-smart-contracts.md @@ -91,11 +91,11 @@ In addition, Neo3-Boa has an interface for contracts that adhere to the NEP-17 s # calling_nep17_contract.py from boa3.sc.compiletime import public from boa3.sc.contracts import ContractManagement -from boa3.sc.types import Nep17Contract +from boa3.sc.types import Nep17Contract, UInt160 @public -def calling_other_contract(my_contract_hash: str) -> str: +def calling_other_contract(my_contract_hash: UInt160) -> str: nep_17_contract: Nep17Contract = ContractManagement.get_contract(my_contract_hash) return nep_17_contract.symbol() ```