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