Calling Other Contracts

Invoking Other Smart Contracts

can call other contracts using the CallContract method. This method receives the script hash of the contract to call, the method to invoke, and the parameters to pass to the method.

The callback OnNEP17Payment Method

If the recipient is a smart contract, we need to check if it implements the onNEP17Payment method. If it does, then we need to call it passing the correct parameters. The onNEP17Payment method is as follows:

The implementation of the OnNEP17Payment method is up to the developer. If they want to refuse the transfer, they must throw an exception.

Using the ContractManagement Native Contract

Use the built-in ContractManagement native contract to verify if the recipient is a smart contract and if it implements the onNEP17Payment method. If it does, then we need to call it passing the correct parameters.

Checking if the Recipient is a Smart Contract

Update the contract code to check if the recipient is a smart contract. If it is, then we need to check if it implements the onNEP17Payment method. If it does, then we need to call it passing the correct parameters.

We need to add the code above if we want to make sure the COIN contract is compatible with the standard. If we don’t add this code, the contract will still work, but it won’t be NEP-17 compliant.

Let’s add some metadata to the COIN contract. The metadata is used by explorers and other applications to display information about the . The metadata also contains information about permissions and other details about the token. By default, contracts can’t call other contracts. We need to add it to the contract manifest.