Crates.io | delegator |
lib.rs | delegator |
version | 3.0.0 |
source | src |
created_at | 2022-03-23 11:37:27.550063 |
updated_at | 2022-03-23 11:37:27.550063 |
description | ink! delegator contract |
homepage | |
repository | |
max_upload_size | |
id | 555178 |
size | 106,530 |
The delegator smart contract is our showcase for executing other smart contracts on-chain.
It consists in total of 4 different smart contract:
i32
value that can be incremented or decrementedIn order to test this bundle of smart contracts you need to execute the following steps.
You can upload the contracts using our Contracts UI.
If you want to test it locally, our substrate-contracts-node
is an easy way to get a local smart contract chain running.
Compile all contracts using the ./build-all.sh
script.
You will receive the respective .contract
bundles for all the smart contracts in the target/ink/
folder:
target/ink/delegator.contract
target/ink/adder/adder.contract
target/ink/subber/subber.contract
target/ink/accumulator/accumulator.contract
Upload the .contract
bundle of Accumulator, Adder and Subber to the chain.
Note down the respective code hashes of the uploaded contracts. You can
copy the contract hashes from the page of uploaded contracts:
Instantiate the Delegator smart contract given all of the code hashes and a starting value.
Make sure the endowment is big enough (if you're using our substrate-contracts-node
it's 1000000
).
The Delegator smart contract will take over the work of instantiating the other smart contracts for you.
Now you are able to run the operations provided by the Delegator smart contract.
Namely delegate
to delegate the call to either the Adder or the Subber to either increase or decrease
the value stored in the Accumulator smart contract respectively and switch
to switch the currently
delegated-to smart contract.
The initial delegated-to smart contract is the Adder.
Note:
Depending on your Substrate version you might encounter a bug with the pre-filled gas estimation of the UI and get the errorExtrinsicFailed: OutOfGas
. As a workaround set the maximum allowed gas manually (e.g. to 5000).