Wrapped ICP (WICP) - A composable and interoperable wrapped version of ICP.

Related tags

Utilities wicp
Overview

Frame 22

Wrapped ICP - WICP

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.


🧰 Interacting with Wrapped ICP (WICP) - On Mainnet (DFX)

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.


✒️ Update Calls

All update functions are allowed to trap, instead of returning an error in order to take advantage of the canisters automatic, atomic state rollback.


Deposit ICP to mint an WICP balance - mint

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 0

Now 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)'

Unwrap your WICP and regain a balance of ICP - withdraw

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")'

Transfer WICP to Another WICP Balance - transfer

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)"

Set an Allowance to Another Identity - approve

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)"

Transfer WICP on Another User's Behalf - transferFrom

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)"

📡 Query Calls

The query calls in this section do not require any fee as they are only reading information, not modifying it.

Check your Balance - balanceOf

Returns the balance of user who.

​​dfx canister --network=ic --no-wallet call --query utozz-siaaa-aaaam-qaaxq-cai balanceOf "(principal \"who-account-principal\")"

Check the set allowance for an ID - allowance

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\")"

Get token logo - getLogo

Returns the logo of Wrapped ICP (WICP).

dfx canister --network=ic --no-wallet call --query utozz-siaaa-aaaam-qaaxq-cai getLogo

Get token name - name

Returns the name of Wrapped ICP (WICP).

dfx canister --network=ic --no-wallet call --query utozz-siaaa-aaaam-qaaxq-cai name

Get token symbol - symbol

Returns the symbol of the token.

dfx canister --network=ic --no-wallet call --query utozz-siaaa-aaaam-qaaxq-cai symbol

Get token decimals - decimals

Returns the decimals of the token.

dfx canister --network=ic --no-wallet call --query utozz-siaaa-aaaam-qaaxq-cai decimals

Get total supply of token - totalSupply

Returns the total supply of the token.

dfx canister --network=ic --no-wallet call --query utozz-siaaa-aaaam-qaaxq-cai totalSupply

Get token’s metadata - getMetadata

Returns the metadata of the token.

dfx canister --network=ic --no-wallet call --query utozz-siaaa-aaaam-qaaxq-cai getMetadata

historySize

Returns the history size.

dfx canister --network=ic --no-wallet call --query utozz-siaaa-aaaam-qaaxq-cai historySize
Comments
  • chore: 🤖 add fleek testnet to canister_ids.json

    chore: 🤖 add fleek testnet to canister_ids.json

    Why?

    The reason why I'd want to use it, is that I'd like to persist the canister id when deploying to the fleek remote replica, which wicp and other services are deployed for the marketplace project. Here's the source https://github.com/Psychedelic/wicp/blob/main/.gitignore#L12 and let me know if I should handle this separately or if I can indeed add to the original repo.

    How?

    • adds canister_ids.json
    opened by heldrida 2
  • `getLogo` not implemented

    `getLogo` not implemented

    I tried the following

    ❯ dfx canister --network=ic call --query utozz-siaaa-aaaam-qaaxq-cai getLogo
    
    The Replica returned an error: code 3, message: "IC0302: Canister utozz-siaaa-aaaam-qaaxq-cai has no query method 'getLogo'"
    
    opened by letmejustputthishere 2
  • chore: 🤖 add mainnet location to canister id

    chore: 🤖 add mainnet location to canister id

    Why?

    Communicate clearly where the mainnet wicp is located at by adding to the canister ids json file.

    Demo?

    Optionally, provide any screenshot, gif or small video.

    opened by heldrida 0
  • chore: 🤖 optimize build

    chore: 🤖 optimize build

    Why?

    Clear and short explanation here.

    How?

    • Done A (replace with a breakdown of the steps)
    • Done B
    • Done C

    Tickets?

    Contribution checklist?

    • [ ] The commit messages are detailed
    • [ ] It does not break existing features (unless required)
    • [ ] I have performed a self-review of my own code
    • [ ] Documentation has been updated to reflect the changes
    • [ ] Tests have been added or updated to reflect the changes
    • [ ] All code formatting pass
    • [ ] All lints pass
    • [ ] All tests pass

    Security checklist?

    • [ ] Injection has been prevented (parameterized queries, no eval or system calls)
    • [ ] Sensitive data has been identified and is being protected properly

    Demo?

    Optionally, provide any screenshot, gif or small video.

    opened by heldrida 0
  • chore: 🤖 add fleek testnet to dfx.json

    chore: 🤖 add fleek testnet to dfx.json

    Why?

    The dfx.json should have the fleek testnet, as it'll be required for automating deployments e.g. staging https://github.com/Psychedelic/nft-marketplace-fe/pull/71 which depends on this PR

    How?

    • Add feek testnet network to dfx.json
    opened by heldrida 0
  • Backup

    Backup

    Why?

    Clear and short explanation here.

    How?

    • Done A (replace with a breakdown of the steps)
    • Done B
    • Done C

    Tickets?

    • N/A

    Contribution checklist?

    • [ ] The commit messages are detailed
    • [ ] It does not break existing features (unless required)
    • [ ] I have performed a self-review of my own code
    • [ ] Documentation has been updated to reflect the changes
    • [ ] Tests have been added or updated to reflect the changes
    • [ ] All code formatting pass
    • [ ] All lints pass
    • [ ] All tests pass

    Security checklist?

    • [ ] Injection has been prevented (parameterized queries, no eval or system calls)
    • [ ] Sensitive data has been identified and is being protected properly

    Demo?

    Optionally, provide any screenshot, gif or small video.

    opened by scott-dn 0
  • fix: 🐛 Update README.md

    fix: 🐛 Update README.md

    Why?

    wrong method method name for retrieving the logo from the canister.

    How?

    updated readme

    Tickets?

    • closes #21

    Contribution checklist?

    • [x] The commit messages are detailed
    • [x] It does not break existing features (unless required)
    • [x] I have performed a self-review of my own code
    • [x] Documentation has been updated to reflect the changes
    • [ ] Tests have been added or updated to reflect the changes
    • [ ] All code formatting pass
    • [ ] All lints pass
    • [ ] All tests pass

    Security checklist?

    • [ ] Injection has been prevented (parameterized queries, no eval or system calls)
    • [ ] Sensitive data has been identified and is being protected properly

    Demo?

    Optionally, provide any screenshot, gif or small video.

    opened by letmejustputthishere 0
  • feat: tooling and github ci

    feat: tooling and github ci

    feat: healthcheck and deploy scripts feat: cap submodule for local testing feat: github ci healthcheck feat: conventional commits title checks feat: pull request template

    opened by ozwaldorf 0
  • I tried wrapping my ICP on Cigdao Swap

    I tried wrapping my ICP on Cigdao Swap

    I tried wrapping my ICP on Cigdao Swap but unfortunately, no contract was created but instead a direct transfer of my 1.02 ICP to cc659fe529756bae6f72db9937c6c60cf7ad57eb4ac5f930a75748927aab469a

    Transaction hash is below: https://icscan.io/transaction/dac2e8ee90505a66ebcd55b4d27e91868239f7579c37575c11c811c3c6d6e3e1

    My intention was to wrap my ICP into WICP and swap WICP to YC

    Please help fix this issue.

    opened by olaitantm 0
  • feat: v2

    feat: v2

    Why?

    • v2

    How?

    • Manual reply
    • Rust safe
    • Improve internal data structure
    • Cap failover
    • Integration test

    Tickets?

    • N/A

    Contribution checklist?

    • [x] The commit messages are detailed
    • [x] It does not break existing features (unless required)
    • [x] I have performed a self-review of my own code
    • [x] Documentation has been updated to reflect the changes
    • [x] Tests have been added or updated to reflect the changes
    • [x] All code formatting pass
    • [x] All lints pass
    • [x] All tests pass

    Security checklist?

    • [x] Injection has been prevented (parameterized queries, no eval or system calls)
    • [x] Sensitive data has been identified and is being protected properly

    Demo?

    Optionally, provide any screenshot, gif or small video.

    opened by scott-dn 0
Owner
Psychedelic
Decentralized product studio focused on building products on Web3, Ethereum, and the Internet Computer.
Psychedelic
Verbump - A simple utility written in rust to bump and manage git semantic version tags.

Verbump - A simple utility written in rust to bump and manage git semantic version tags.

Sarat Chandra 6 May 6, 2022
A lightning fast version of tmux-fingers written in Rust, copy/pasting tmux like vimium/vimperator

tmux-thumbs A lightning fast version of tmux-fingers written in Rust for copy pasting with vimium/vimperator like hints. Usage Press ( prefix + Space

Ferran Basora 598 Jan 2, 2023
A simplified but faster version of Routerify

Routerify lite Routerify-lite is a simplified but faster version of Routerify. It only provides below functions: path matching error handling Why not

jinhua luo 7 Dec 30, 2022
🦸‍♂️ Recast migrates your old extensions to AndroidX, making them compatible with the latest version of Kodular.

Recast Recast helps make your old extensions compatible with Kodular Creator version 1.5.0 or above. Prerequisites To use Recast, you need to have Jav

Shreyash Saitwal 13 Dec 28, 2022
Rust version of tomnomnom/waybackurls

wayback-rs Rust version of tomnomnom/waybackurls Command line interface for fetching url from Wayback Machine, CommonCrawl, VirusTotal.

null 3 Oct 22, 2021
Incremental, multi-version remote backup tool for block devices.

bsync Incremental, multi-version remote backup tool for block devices. The on-disk backup format is a SQLite database and I've been dogfooding this on

Heyang Zhou 7 Aug 21, 2022
Convert Hygea calendar to an iCal file to easily import it to Google Calendar (Rust version)

Hygea to iCal Goal Hygea provides a calendar via PDF and an application called Recycle. I just wanted to use an iCal file to import it in my calendar.

Guillaume Quittet 2 Oct 28, 2021
A rust-based version of the popular dnsgen python utility

ripgen A rust-based version of the popular dnsgen python utility. ripgen is split into two main parts: ripgen: A CLI utility that calls into ripgen_li

resync 198 Jan 2, 2023
Ferris has to escape the creepers using a modified version of Dijkstra called A*

Ferris has to escape the creepers using a modified version of Dijkstra called A*

Security Union 13 Oct 30, 2022
A future version of Pokétwo

poketwo-next Pokétwo brings the Pokémon experience to Discord. Catch randomly-spawning pokémon in your servers, trade them to expand your collection,

Pokétwo 13 Aug 20, 2022
Rc version `tokio-rs/bytes`

RcBytes The aim for this crate is to implement a Rc version bytes, which means that the structs in this crate does not implement the Sync and Send. Th

Al Liu 2 Aug 1, 2022
Fusion is a cross-platform App Dev ToolKit build on Rust . Fusion lets you create Beautiful and Fast apps for mobile and desktop platform.

Fusion is a cross-platform App Dev ToolKit build on Rust . Fusion lets you create Beautiful and Fast apps for mobile and desktop platform.

Fusion 1 Oct 19, 2021
List of Persian Colors and hex colors for CSS, SCSS, PHP, JS, Python, and Ruby.

Persian Colors (Iranian colors) List of Persian Colors and hex colors for CSS, SCSS, PHP, C++, QML, JS, Python, Ruby and CSharp. Persian colors Name H

Max Base 12 Sep 3, 2022
Northstar is a horizontally scalable and multi-tenant Kubernetes cluster provisioner and orchestrator

Northstar Northstar is a horizontally scalable and multi-tenant Kubernetes cluster provisioner and orchestrator. Explore the docs » View Demo · Report

Lucas Clerisse 1 Jan 22, 2022
Time related types (and conversions) for scientific and astronomical usage.

astrotime Time related types (and conversions) for scientific and astronomical usage. This library is lightweight and high performance. Features The f

Michael Dilger 3 Aug 22, 2022
A Diablo II library for core and simple client functionality, written in Rust for performance, safety and re-usability

A Diablo II library for core and simple client functionality, written in Rust for performance, safety and re-usability

null 4 Nov 30, 2022
UnTeX is both a library and an executable that allows you to manipulate and understand TeX files.

UnTeX UnTeX is both a library and an executable that allows you to manipulate and understand TeX files. Usage Executable If you wish to use the execut

Jérome Eertmans 1 Apr 5, 2022
A convenient tracing config and init lib, with symlinking and local timezone.

clia-tracing-config A convenient tracing config and init lib, with symlinking and local timezone. Use these formats default, and can be configured: pr

Cris Liao 5 Jan 3, 2023
Code examples, data structures, and links from my book, Rust Atomics and Locks.

This repository contains the code examples, data structures, and links from Rust Atomics and Locks. The examples from chapters 1, 2, 3, and 8 can be f

Mara Bos 338 Jan 6, 2023