How we can receive some ICP from the caller in a canister method.
For example :
public shared(msg) func receiveICP() : async Bool {
sender : Principal = msg.caller;
//How i can receive the ICP like msg.data ? or something like that
}
Here how we can receive ICP from the caller similar to data in soldity. We get the ether send when calling a function.
For ICP thereās a [transaction_notification](https://github.com/dfinity/ic/blob/master/rs/rosetta-api/ledger_canister/src/main.rs#L259) function to implement on a canister side to be notified of a received ICP transfer (hint. TransactionNotification type)
ICP is different, itās more like an erc20 token on ethereum. Thereās is a ledger canister that holds the balances and has a āsendā and āaccount_balanceā func. When you send ICP you are not actually sending anything, just making a canister call to the ledger canister. The only way to send ICP to a canister is to call the ICP ledger āsendā (like you would sending an erc20 token)
The ICP ledger does have a notify call, which then notifies the receiver of your tx. So you can use that to trigger something within your canister (e.g. mint ICO tokens or whatever). This uses the transaction notification endpoint. Thereās not a lot of info out there, we do have an example we are working on but we are being held up byā¦
Thereās no point right now in sending ICP to canisters because canisters can not āsendā these out. You have to be whitelisted to send ICP from a canister currently, so any ICP sent to it will be held there until this is resolved
This is one reason we are working on wtctoken.com - we can make it fairly easy for users to convert ICP to WTC and then send WTC to canisters for the purpose of say an ICO
Thanks alot Stephen.
TransactionNotification is the one we need to depend on now.
Question here
The internet Identity have principals right ? Are they capable of receiving ICP ?
Then the token is very local to canisters. How we can get the number of tokens available from a particular canisters ?
Example
dfx canister call sgymv-uiaaa-aaaaa-aaaia-cai transfer ā(principal āh6m2n-nrloa-igrxa-r3psa-6nvfe-e3qj2-aowjt-skmcn-z6i6j-sx5b7-paeā, 1000:nat)ā
This is working now
dfx canister call sgymv-uiaaa-aaaaa-aaaia-cai balanceOf ā(principal āh6m2n-nrloa-igrxa-r3psa-6nvfe-e3qj2-aowjt-skmcn-z6i6j-sx5b7-paeā)ā
returns 1_000
ic.rocks will show these tokens 1_000 when i deploy this in Mercury mainnet ?
Or we need to get the details only from the canister ?
The hex address (64 long hex string) is also known as the AccountIdentifier, and is constructed using a sha224 of the principal, an index represented as 32 bytes, and the a checksum added in. We built some tooling around working with it. This allows a single principal to have 2 ** 32 seperate sub accounts.
Currently ICP can only be transferred to and from these AccountIdentifiers, some of the token standards only use the Principal as itās easier to work with. The token standard we are building (and using for $WTC) allows you to send to either address and it will arrive to the user. These EXT tokens are also supported in our wallet (stoicwallet.com) - we have an erc20 like example too
It is Fungible token, so it should have totalSupply already in place right ?
But no where it is mentioned how many tokens to generate in the code erc20.mo code ?
Does this function let the canister accept cycles ?
public func acceptCycles() : async () {
let available = Cycles.available();
let accepted = Cycles.accept(available);
assert (accepted == available);
};
Currently it is hard to mint WTC - check out the website which lists more detail, but you have to convert ICP to cycles in your cycles wallet, and then you need to send that to our token contract to mint WTC.
We are working on a simple minter tho, where you can just send ICP to a canister and it will automatically convert it to ICP. Once that is up and running it will be very simple to top up using WTC.
We are also adding a feature into Stoic (it was in an earlier version) where you can topup canisters using ICP directly (so you enter the canister ID, an amount of ICP and it will convert it and send the cycles).