# HMIP20 hmip20 smart contract for hermit network. ### download ```bash git clone https://github.com/HermitMatrixNetwork/hmip20.git ``` ## before compile ```bash apt update && apt install -y binaryen clang ``` ## compile ```bash cd himp20 cargo test make compile-optimized ``` this commone will output a file `contract.wasm.gz`. ## Usage of Hmip20 Contract ### storage contract code ```bash ghmd tx compute store contract.wasm.gz --from a --gas 1000000 --gas-prices 0.25ughm ``` use `ghmd q compute list-code`, find the number of upload contract ### instantiate a token contract ```bash ghmd tx compute instantiate \ '{"name":"","symbol":"","admin":"","decimals":,"initial_balances":[{"address":"","amount":""}],"prng_seed":"","config":{"public_total_supply":,"enable_deposit":,"enable_redeem":,"enable_mint":,"enable_burn":}}' \ --label \ --from ``` #### config your contract ```json "config":{ "public_total_supply":, "enable_deposit":, "enable_redeem":, "enable_mint":, "enable_burn": } ``` ## execute token contract #### deposit ```bash ghmd tx compute execute '{"deposit":{}}' --amount 1000000ughm --from ``` #### Redeem ```bash ghmd tx compute execute '{"redeem": {"amount": ""}}' --from ``` #### Transfer ```bash '{"transfer":{"amount":"","recipient":""}}' ``` #### Send ```bash '{"send":{"amount": , "recipient": }}' ``` #### BatchTransfer ```bash '{"batch_transfer":{"actions":[{"amount": , "recipient": }]}}' ``` #### BatchSend ```bash '{"batch_send":{"actions":[{"amount":, "recipient":}]}}' ``` #### Burn ```bash '{"burn":{"amount": }}' ``` #### RegisterReceive ```bash '{"register_receive": {"code_hash": }}' ``` #### CreateViewingKey ```bash '{"create_viewing_key":{"entropy": }' ``` #### SetViewingKey ```bash ghmd tx compute execute '{"set_viewing_key": {"key": ""}}' --from ``` #### IncreaseAllowance ```bash '{"increase_allowance":{"spender": , "amount": }' ``` #### DecreaseAllowance ```bash '{"decrease_allowance":{"spender": ,"amount":}}' ``` #### TransferFrom ```bash '{"transfer_from":{"amount":, "owner":, "recipient":}}' ``` #### SendFrom ```bash '{"send_from":{"amount":, "owner":, "recipient":}' ``` #### BatchTransferFrom ```bash '{"batch_transfer_from":{"actions":[{"amount":, "owner":, "recipient":}]}' ``` #### BatchSendFrom ```bash '{"batch_send_from":{"actions":[{"amount":, "owner":, "recipient":}]}' ``` #### BurnFrom ```bash '{"burn_from":{"amount":""", "owner":""}' ``` #### BatchBurnFrom ```bash '{"batch_burn_from":{"actions":[{"amount":""", "owner":""}]}' ``` #### Mint ```bash '{"mint":{"amount":"","recipient":""}}' ``` #### BatchMint ```bash '{"batch_mint":{"actions":[{"amount":"","recipient":""}]}}' ``` #### ChangeAdmin ```bash '{"change_admin":{"address":""}}' ``` #### SetContractStatus ```bash '{"set_contract_status":{"level":""}}' // normal_run // stop_all_but_redeems // stop_all ``` #### AddMinters ```bash '{"add_minters":{"minters":["str1","str2"]}}' ``` #### RemoveMinters ```bash '{"remove_minters":{"minters":["str1","str2"]}}' ``` #### SetMinters ```bash '{"set_minters":{"minters":["str1","str2"]}}' ``` #### RevokePermit ```bash '{"revoke_permit":{"permit_name":""}}' ``` ## query token contract info #### TokenInfo ```bash '{"token_info":{}}' ``` #### TokenConfig ```bash ghmd q compute query '{"token_config": {}}' ``` #### ContractStatus ```bash '{"contract_status":{}}' ``` #### ExchangeRate ```bash ghmd q compute query '{"exchange_rate": {}}' ``` #### Minters ```bash '{"minters":{}}' ``` #### WithPermit ```bash // todo '{"with_permit":{"permit":{},"query":""}}' ``` #### Balance ```bash '{"balance":{"address":"","key":"str"}}' ``` #### TransferHistory ```bash '{"transfer_history":{"address":"","key":"","page_size":}}' ``` #### TransactionHistory ```bash '{"transaction_history":{"address":"","key":"","page_size":}' ``` #### Allowance ```bash '{"allowance":{"key":"","owner":"","spender":""}}' ```