Skip to content

Instantly share code, notes, and snippets.

@mhchia
Last active December 27, 2022 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhchia/54fd4c6e88d3f2511c94ad1146d17c5c to your computer and use it in GitHub Desktop.
Save mhchia/54fd4c6e88d3f2511c94ad1146d17c5c to your computer and use it in GitHub Desktop.

I'm trying the step Instantiate the CosmWasm contract in the tutorial. The command in instantiate_egg.sh is copied-pasted from the tutorial but one argument --node tcp://testnet.palomaswap.com:26656 is added to tell palomad about the node. It keeps failing due to "missing field factory_contract".

Environments:

  • palomad version: v0.11.4.
  • Pretty sure ADDRESS, PALOMA_CHAIN_ID, and ETH_ADDRESS are well set.
Error: rpc error: code = Unknown desc = rpc error: code = Unknown desc = failed to execute message; message index: 0: Error parsing into type astroport::oracle::InstantiateMsg: missing field `factory_contract`: instantiate wasm contract failed [!cosm!wasm/wasmd@v0.29.1/x/wasm/keeper/keeper.go:357] With gas wanted: '0' and gas used: '192026' : unknown request
#!/bin/bash
set -euo pipefail
set -x
#set the parameters for the JSON
CHAIN_ID="eth-main"
COMPASS_ID="1400"
CONTRACT_ADDRESS="0x4190cb9bb30f85dafb3adbfdb51e776b3e4028e9"
SMART_CONTRACT_ABI='[{"type": "event", "name": "Transfer", "inputs": [{"name": "_from", "type": "address", "indexed": true}, {"name": "_to", "type": "address", "indexed": true}, {"name": "_tokenId", "type": "uint256", "indexed": true}], "anonymous": false}, {"type": "event", "name": "Approval", "inputs": [{"name": "_owner", "type": "address", "indexed": true}, {"name": "_approved", "type": "address", "indexed": true}, {"name": "_tokenId", "type": "uint256", "indexed": true}], "anonymous": false}, {"type": "event", "name": "ApprovalForAll", "inputs": [{"name": "_owner", "type": "address", "indexed": true}, {"name": "_operator", "type": "address", "indexed": true}, {"name": "_approved", "type": "bool", "indexed": false}], "anonymous": false}, {"type": "event", "name": "Minted", "inputs": [{"name": "eth_address", "type": "address", "indexed": true}, {"name": "paloma_address", "type": "string", "indexed": true}, {"name": "token_id", "type": "uint256", "indexed": true}], "anonymous": false}, {"type": "event", "name": "SetMinter", "inputs": [{"name": "new_minter", "type": "address", "indexed": true}, {"name": "old_minter", "type": "address", "indexed": true}], "anonymous": false}, {"type": "constructor", "stateMutability": "nonpayable", "inputs": []}, {"type": "function", "name": "name", "stateMutability": "nonpayable", "inputs": [], "outputs": [{"name": "", "type": "string"}]}, {"type": "function", "name": "symbol", "stateMutability": "nonpayable", "inputs": [], "outputs": [{"name": "", "type": "string"}]}, {"type": "function", "name": "supportsInterface", "stateMutability": "pure", "inputs": [{"name": "interface_id", "type": "bytes4"}], "outputs": [{"name": "", "type": "bool"}]}, {"type": "function", "name": "balanceOf", "stateMutability": "view", "inputs": [{"name": "_owner", "type": "address"}], "outputs": [{"name": "", "type": "uint256"}]}, {"type": "function", "name": "ownerOf", "stateMutability": "view", "inputs": [{"name": "_tokenId", "type": "uint256"}], "outputs": [{"name": "", "type": "address"}]}, {"type": "function", "name": "getApproved", "stateMutability": "view", "inputs": [{"name": "_tokenId", "type": "uint256"}], "outputs": [{"name": "", "type": "address"}]}, {"type": "function", "name": "isApprovedForAll", "stateMutability": "view", "inputs": [{"name": "_owner", "type": "address"}, {"name": "_operator", "type": "address"}], "outputs": [{"name": "", "type": "bool"}]}, {"type": "function", "name": "transferFrom", "stateMutability": "nonpayable", "inputs": [{"name": "_from", "type": "address"}, {"name": "_to", "type": "address"}, {"name": "_tokenId", "type": "uint256"}], "outputs": []}, {"type": "function", "name": "safeTransferFrom", "stateMutability": "nonpayable", "inputs": [{"name": "_from", "type": "address"}, {"name": "_to", "type": "address"}, {"name": "_tokenId", "type": "uint256"}], "outputs": []}, {"type": "function", "name": "safeTransferFrom", "stateMutability": "nonpayable", "inputs": [{"name": "_from", "type": "address"}, {"name": "_to", "type": "address"}, {"name": "_tokenId", "type": "uint256"}, {"name": "_data", "type": "bytes"}], "outputs": []}, {"type": "function", "name": "approve", "stateMutability": "nonpayable", "inputs": [{"name": "_approved", "type": "address"}, {"name": "_tokenId", "type": "uint256"}], "outputs": []}, {"type": "function", "name": "setApprovalForAll", "stateMutability": "nonpayable", "inputs": [{"name": "_operator", "type": "address"}, {"name": "_approved", "type": "bool"}], "outputs": []}, {"type": "function", "name": "mint", "stateMutability": "nonpayable", "inputs": [{"name": "_to", "type": "address"}, {"name": "_tokenId", "type": "uint256"}, {"name": "_paloma_address", "type": "string"}], "outputs": [{"name": "", "type": "bool"}]}, {"type": "function", "name": "set_minter", "stateMutability": "nonpayable", "inputs": [{"name": "_minter", "type": "address"}], "outputs": []}, {"type": "function", "name": "tokenURI", "stateMutability": "view", "inputs": [{"name": "tokenId", "type": "uint256"}], "outputs": [{"name": "", "type": "string"}]}, {"type": "function", "name": "minter", "stateMutability": "view", "inputs": [], "outputs": [{"name": "", "type": "address"}]}]'
# Escape the ABI json.
SMART_CONTRACT_ABI="$(echo "$SMART_CONTRACT_ABI" | jq -R -s .)"
JSON="$(cat <<EOT
{
"target_contract_info": {
"chain_id": "$CHAIN_ID",
"compass_id": "$COMPASS_ID",
"contract_address": "$CONTRACT_ADDRESS",
"smart_contract_abi": $SMART_CONTRACT_ABI
}
}
EOT
)"
#palomad command to instantiate the contract
exec palomad tx wasm instantiate 3 \
"$JSON" \
--from "$ADDRESS" \
--fees 400ugrain \
--label "egg-contest" \
--chain-id "$PALOMA_CHAIN_ID" \
--gas auto \
-y --no-admin -b block \
--node tcp://testnet.palomaswap.com:26656
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment