SmartContract
Smart contracts allow running credible transactions without third parties. These transactions are trackable and irreversible. The DLT Adapter offers a set of API operations to manage all options with smart contracts in a DLT network.
Deploy Smart Contract
First of all, we need to check the available accounts and select an address with enough balance to operate with. This is explained in the Common section.
Once we have our smart contract developed, we can adapt a Smart Contract deployment order to get the response raw to deploy the smart contract on DLT network. We need:
- A raw serialized binary compilation
- An ABI of the contract stored in an accessible point
- The constructor method of the contract
- Optionally the params of this method
- The selected address as sender.
You can see the technical documentation, and an example of the call here.
To deploy the adapted deployment transaction, we can use the send transaction call of the Wallet-Hub component to finish the deployment.
To locate the smart contract deployment transaction, we can call the DLT Broker component, with the selected address as sender to get the contract address.
Once the contract address is saved, you will need to register the smart contract.
Register Smart Contract in Hancock
Once you finished the deployment, we can register the smart contract to operate with it in Hancock.
You can see the technical documentation, and an example of the call here.
Find a Smart Contract
To check the registered smart contracts, we can get a list of all contracts registered in Hancock. Use the call described here.
Invoke a Smart Contract
After deploying and registering our contract, we can use all operations of the contract with invoke operation.
We can adapt the invoke order to get the response raw to invoke an operation of the contract. We need:
- The operation name
- optionally the params of the method
- The selected address as sender.
You can see the technical documentation, and an example of the call here.
Anyway, we can operate with smart contract deployed on a DLT network without registering the contract beforehand in Hancock. In that case, apart from the parameters, we need the ABI of the contract Check the technical call to know more details.