Secret Contracts
Last updated
Was this helpful?
Last updated
Was this helpful?
To upload a contract:
--source
: Optional tarball of the source code, so your contract will be .
--builder
: Optional docker image used to compile ./contract.wasm.gz
, so that your contract will be . This is important for reproducible builds so you should figure out the exact version of scrtlabs/secret-contract-optimizer
that you were using.
To get the contract's code ID:
This will output a long JSON output, like this:
You will then find the code id under the logs.events array on the object with key code_id.
In order to instantiate a contract, simply run the following command:
Where $CODE_ID
is the code id that you got from the command above and $INIT_INPUT_MSG
is a JSON encoded version of the init message required in your contract. This message will depend on your contract.
To get the contract's address:
You will find the contract address under logs.events.array on the object with key contract_address.
Executing a contract is just as simple, simply use
Where$CONTRACT_ADDRESS
is the address you found above, and $EXEC_INPUT_MSG
is the message containing the handle function you're trying to execute. This message will heavily depend on your contract, but generally the format follows the following pattern:
You can also execute a function on a contract by using the contract's label over the address, like so:
Please note that this is not recommended as its easy for someone to deploy a contract with a similar enough label where you could possibly execute the wrong contract by typoing, but it's much harder for the same thing to happen with an address.
In order to read the output of a transaction, such as the output of a handle function called by compute execute or a contract that has just been instantiated you would run the following
Where $HASH is your transaction hash.
Querying a smart contract is just as easy, you just execute the following:
Where$CONTRACT_ADDRESS
is the address of your contract and $QUERY_INPUT_MSG
is the query you're trying to run. The output will depend on your contract.