Initialise the Contract
Now it's time for the fun stuff. Let's configure and get this contract up-and-running.
Now we've uploaded the contract, now we need to initialise it.
We're using the Poodle Coin example here - $POOD was the first meme coin deployed to a Juno testnet.
Choose another name rather than Poodle Coin/POOD, as this is likely already taken on the testnet.

Generate JSON with arguments

To generate the JSON, you can use jq, or, if you're more familiar with JS/node, write a hash and encode it using the node CLI.
This example uses the node REPL. If you have node installed, just type node in the terminal and hit enter to access it.
1
> const initHash = {
2
name: "Poodle Coin",
3
symbol: "POOD",
4
decimals: 6,
5
initial_balances: [
6
{ address: "<validator-self-delegate-address>", amount: "12345678000"},
7
]
8
};
9
< undefined
10
> JSON.stringify(initHash);
11
< '{"name":"Poodle Coin","symbol":"POOD","decimals":6,"initial_balances":[{"address":"<validator-self-delegate-address>","amount":"12345678000"}]}'
Copied!

Instantiate the contract

Note that if you use rich types like CosmWasm's Uint128 then they will be strings from the point of view of JSONSchema. If you have an int, you do not need quotes, e.g. 1 - but for a Uint128 you will need them, e.g. "1".
Note also that the --amount is used to initialise the new account associated with the contract.
In the example below, 6 is the value of $CODE_ID.
1
junod tx wasm instantiate 6 \
2
'{"name":"Poodle Coin","symbol":"POOD","decimals":6,"initial_balances":[{"address":"<validator-self-delegate-address>","amount":"12345678000"}]}' \
3
--amount 50000ujuno --label "Poodlecoin erc20" --from <your-key> --chain-id <chain-id> --gas auto -y
Copied!
If you have set $CODE_ID in your shell, you can instead run:
1
junod tx wasm instantiate $CODE_ID \
2
'{"name":"Poodle Coin","symbol":"POOD","decimals":6,"initial_balances":[{"address":"<validator-self-delegate-address>","amount":"12345678000"}]}' \
3
--amount 50000ujuno --label "Poodlecoin erc20" --from <your-key> --chain-id <chain-id> --gas auto -y
Copied!
If this succeeds, look in the output and get contract address from output e.g juno1a2b.... or run:
1
CONTRACT_ADDR=$(junod query wasm list-contract-by-code $CODE_ID --output json | jq -r '.contracts[0]')
Copied!
This will allow you to query using the value of $CONTRACT_ADDR
1
junod query wasm contract $CONTRACT_ADDR
Copied!
Last modified 5d ago