-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Usage of tokens from within other canister #2
Comments
So remove the dep and remove erc20 as a canister - anything listed in the canister section defines one to be created. So your json should just be:
Then in main.mo include the erc20.mo file as an import, e.g.:
and then to create the token in code you would do something like:
We recommend using the multi-canister approach due to cost savings. Currently it cost about 1T cycles to originate a new canister, where as the multi-canister approach costs about 50M cycles per token. |
I'll look to add an example of this soon too |
Thank you! I got a couple of steps further with your help. But a full example with usage etc. would be very helpful. I think it would help a lot of new ic devs that are trying to get into motoko & tokens if they can kickstart without fighting through the motoko documentation. |
I'm struggling to figure out how to use the token examples / standards within other canisters.
Scenario: I want to create a token not from a frontend, but another "backend" canister instead.
Expected behavior:
I can deploy my canister with the token standard as a dependency and create new tokens whenever I want.
I configured my test env like this:
Actual behavior:
Dfinity fails with "Invalid data: Expected arguments but found none.".
To my understanding, this happens because the tokens are defined as actors so that they can be deployed on their own. But in my case, this throws an error because dfinity tries to deploy the erc20 dependency (which would create a token).
Now I understand I can remove the "actor" and just use the token as a class, but I don't know if that is the desired behavior here.
What do you suggest?
The text was updated successfully, but these errors were encountered: