Note: The Docker container will not work if you are using an M1 chip.
Note: The localsecret docker container can be stopped by CTRL+C
sudo
privileges:Note:sudo docker run
privileges will only need to be given once to run the SecretNetwork docker container normally i.e withoutsudo
privileges.
Note: In a new terminal
test
keyring backend, which makes it easier for local development and testing.exit
when you are donecargo-generate
here. ​tests/
directory and run as:ctrl+shift+p
JavaScript Debug Terminal
and press Enter
npx ts-node integration.ts
discovery migrate
during the Cosmos deploy-execute process which handles both the deploying and creation of the contract instance. This process consists of 3 steps rather than 2 for Ethereum smart contracts. You can read more about the logic behind this decision, and other comparisons to Solidity, in the cosmwasm documentation.secretcli
, using these steps to download the CLI and add its location to your PATH.Note: At this time the Secret Network Light Client is not available for Macs.
chain-id
to pulsar-2
. Below there is also a config setting to point to the test
keyring backend which allows interaction with the testnet and the contract without providing an account password each time.Note: To reset yourkeyring-backend
, usesecretcli config keyring-backend os
.
secret1...
. Copy/paste it to get some testnet SCRT from the faucet.Note: The Secret faucet should fund your testnet account with ~100000000 uscrt. If you query for your account balance before the network has sent and synced the funds sent to your Secret address you will see "balances":[] — please wait for faucet tx to complete.
code_id
in the logs; which you'll use to create an instance of the contract.CODE_ID
value below to the code_id
by querying the txhash. There will be a code_id
in the logs section under events/attributes in the query.Note: A unique label for the contract will need to be made for the contract to be instantiated. If the label is not unique you will get the following error: "Error: label already exists. You must choose a unique label for your contract instance".
src/
) has these files:contract.rs
for contract logic, contract entry points are init
, handle
and query
functions.init
in contract.rs initializes the storage, specifically the current count and the signer/owner of the instance being initialized.handle
, a generic handler for all functions writing to storage, the counter can be incremented and reset. These functions are provided the storage and the environment, the latter's used by the reset
function to compare the signer with the contract owner.query
for all functions reading state, we only have query_count
, returning the counter state.state.rs
file defines the State struct, used for storing the contract data, the only information persisted between multiple contract calls.msg.rs
file is where the InitMsg parameters are specified (like a constructor), the types of Query (GetCount) and Handle[r] (Increment) messages, and any custom structs for each query response.contract.rs
file itself:InitCallback
, HandleCallback
, and Query
traits defined in the utils package.