Wrapped ICP (WICP) is a wrapped version of the IC's native token, ICP. Each WICP will be backed 1:1 with ICP, meaning that 1 WICP will always have the exact same value as 1 ICP. The only difference is that, unlike ICP, WICP uses the DIP20 fungible token standard that is specifically designed to allow for interoperability between dApps and other tokens.
In order to interact with the Internet Computer mainnet version of the Wrapped ICP (WICP) canister, you need the address.
- WICP Canister ID:
utozz-siaaa-aaaam-qaaxq-cai - WICP Account ID:
cc659fe529756bae6f72db9937c6c60cf7ad57eb4ac5f930a75748927aab469a
You have to use this address (Canister ID) to make your calls, with the exception of the Account ID during the mint.
All update functions are allowed to trap, instead of returning an error in order to take advantage of the canisters automatic, atomic state rollback.
Using the mint method is done in two steps. First, we need to make a transfer call at the ICP ledger to the WICP account ID. Using the following command you’ll be returned the block height when your transaction was approved.
dfx ledger --network ic transfer --amount value "cc659fe529756bae6f72db9937c6c60cf7ad57eb4ac5f930a75748927aab469a" --memo 0Now that we have the blockheight of our ICP transfer, we can call the mint method on the WICP canister. In addition, the mint method takes ‘subaccount’, a parameter that allows you to specify if you’ve made the previous ICP transfer from a subaccount. Index 0 is your main account, while all non-zero indices refer to subaccounts.
dfx canister --no-wallet --network ic call utozz-siaaa-aaaam-qaaxq-cai mint '(subaccount, blockheight:nat64)'Calling withdraw unwraps your WICP, burns it, and then unlocks and sends ICP from the WICP canister to the balance of the Principal ID you specify.
The Withdraw method takes two parameters, ‘value’ and ‘to’. Value is an integer that represents the amount of WICP you’d like to withdraw to ICP. To is a string that should be the Principal ID that you wish the ICP to be transferred to.
dfx canister --no-wallet --network ic call utozz-siaaa-aaaam-qaaxq-cai withdraw '(value:nat64, "account id")'You can transfer WICP to any other valid Principal ID. Your balance at the WICP ledger will be deducted and the Principal ID you transfer to, will be incremented.
Transfers ‘value’ (Nat) amount of tokens to user ‘to’ (Principal), returns a TxReceipt which contains the transaction index or an error message.
dfx canister --network=ic --no-wallet call utozz-siaaa-aaaam-qaaxq-cai transfer "(principal \"to-account-principal\", 1000:nat)"You can set an allowance using this method, giving a third-party access to a specific number of tokens they can withdraw from your balance if they want.
An allowance permits the ‘spender’ (Principal) to withdraw tokens from your account, up to the ‘value’ (Nat) amount. If it is called again it overwrites the current allowance with ‘value’ (Nat). There is no upper limit for value, you can approve a larger value than you have, but 3rd parties are still bound by the upper limit of your account balance.
dfx canister --network=ic --no-wallet call utozz-siaaa-aaaam-qaaxq-cai approve "(principal \"third-party-principal-id\", 1000:nat)"Transfers ‘value’ (Nat) amount of tokens from user ‘from’ (Principal) to user ‘to’ (Principal), this method allows canister smart contracts to transfer tokens on your behalf, it returns a TxReceipt which contains the transaction index or an error message.
dfx canister --network=ic --no-wallet call utozz-siaaa-aaaam-qaaxq-cai transferFrom "(principal \"from-account-principal\",principal \"to-account-principal\", 1000:nat)"The query calls in this section do not require any fee as they are only reading information, not modifying it.
Returns the balance of user who.
dfx canister --network=ic --no-wallet call --query utozz-siaaa-aaaam-qaaxq-cai balanceOf "(principal \"who-account-principal\")"Returns the amount which spender is still allowed to withdraw from owner.
dfx canister --network=ic --no-wallet call --query utozz-siaaa-aaaam-qaaxq-cai allowance "(principal \"owner-account-principal\", principal \"spender-account-principal\")"Returns the logo of Wrapped ICP (WICP).
dfx canister --network=ic --no-wallet call --query utozz-siaaa-aaaam-qaaxq-cai getLogoReturns the name of Wrapped ICP (WICP).
dfx canister --network=ic --no-wallet call --query utozz-siaaa-aaaam-qaaxq-cai nameReturns the symbol of the token.
dfx canister --network=ic --no-wallet call --query utozz-siaaa-aaaam-qaaxq-cai symbolReturns the decimals of the token.
dfx canister --network=ic --no-wallet call --query utozz-siaaa-aaaam-qaaxq-cai decimalsReturns the total supply of the token.
dfx canister --network=ic --no-wallet call --query utozz-siaaa-aaaam-qaaxq-cai totalSupplyReturns the metadata of the token.
dfx canister --network=ic --no-wallet call --query utozz-siaaa-aaaam-qaaxq-cai getMetadataReturns the history size.
dfx canister --network=ic --no-wallet call --query utozz-siaaa-aaaam-qaaxq-cai historySize