Deploying Solidity Contract

Deploying Solidity Contract

export FILE_NAME=my-first-solidity
export FILE_PATH=./$FILE_NAME.sol
export KEY_NAME=my-first-key
export CHAIN_ID=my-first-chain-1
export GAS_PRICES=0.15unova

# compile solidity
mkdir build
solc $FILE_PATH --bin --abi -o build

# CREATE opcode
export TX_HASH=$(            \
    minitiad tx evm create   \
    ./build/$FILE_NAME.bin   \
    --from $KEY_NAME         \
    --chain-id $CHAIN_ID     \
    --gas-prices $GAS_PRICES \
    | grep txhash            \
    | sed 's/.*: //'         \
)
    
# CREATE2 opcode
export TX_HASH=$(            \
    minitiad tx evm create2  \
    1:./build/$FILE_NAME.bin \
    --from $KEY_NAME         \
    --chain-id $CHAIN_ID     \
    --gas-prices $GAS_PRICES \
    | grep txhash            \
    | sed 's/.*: //'         \
)

# find contract address from the tx
minitiad q tx $TX_HASH | grep contract -A 1

Interacting with EVM Contract

export CONTRACT_ADDR=0x1
export KEY_NAME=my-first-key

# querying code bytes
minitiad q evm code $CONTRACT_ADDR

# querying state
minitiad q evm state $CONTRACT_ADDR 0x00

# querying erc20 contract address of a denom
minitiad q evm contract-addr-by-denom unova

# querying denom of erc20 contract
minitiad q evm denom $CONTRACT_ADDR

# executing call with no state transition
minitiad q evm call $(minitiad keys show $KEY_NAME -a) \
    $CONTRACT_ADDR        \
    [0x-hex-input-string] \
    --trace               \
    --with-memory         \
    --with-stack          \
    --with-return-data    \
    --with-storage
    
# executing call with state transition
minitiad tx evm call      \
    $CONTRACT_ADDR        \
    [0x-hex-input-string] \
    --from $KEY_NAME      \
    --chain-id $CHAIN_ID  \
    --gas-prices $GAS_PRICES

Conclusion

Now that you have the necessary information on how to deploy your contracts and interact with them on the Initia platform, you are well-equipped to start implementing your projects. For further guidance and practical insights, please refer to upcoming sections that provide examples of EVM contracts. These examples will offer valuable context and demonstrate how to leverage the unique capabilities of the EVM module within the Cosmos ecosystem effectively. Whether you are transitioning existing Ethereum applications or developing new ones, these resources will support you in optimizing your deployment and operational strategies.

Last updated

Logo

© 2024 Initia Foundation, All rights reserved.