eosio.code Permission
Last updated
Last updated
If you're unfamiliar with the eosio.code
permission, it is a special permisssion the must be added to your contract if you want that contract to be able to execute inline actions on other contracts.
For example:
Your contract receives an asset (does not require eosio.code)
Your contract checks some things, and puts some data into a table (does not require eosio.code)
Your contract then needs to send tokens to a user (requires eosio.code)
Adding this permission is quite simple, I will show you 3 different ways to do it.
If you've installed the WAX Contract Development Toolkit on your machine (i.e. if you compile your contracts locally), then you can add this permission using a simple command.
An example with the parameters filled in:
You can also add this permission manually using a block explorer, such as waxblock.io
First, log into waxblock and go to waxblock.io/wallet/permissions/advanced. Next, click on the "Change Permission" menu, and click "active".
You should see a list of your current active keys on the page now. The important thing to keep in mind here, is do not remove or replace the existing keys! What you want to do is click the "Add New +" button.
After clicking this, a new empty row should pop up on the page.
Under the "Type" menu, there is an option called "Account". Select that.
Then, in the "Public Key" menu, type <account_name>@eosio.code
It's worth mentioning one more time - you should still have your existing keys shown on the page, along with the new one you are adding. If you only see the new one, abort!
The next step is to actually submit the transaction - click on the "Update Permission" button, and sign the transaction.
And that's it, your done! If you go to your account page on waxblock, and click on the "Keys" tab, you should now see the eosio.code
account under the "Active" permission. If that's the case, your contract is now able to create inline actions without throwing any errors.
Another option is to use a third party tool built by Nick Kusters, a developer who has been active on WAX for years.
That tool is wax-tools.naw.io. It's pretty straightforward, so doesn't require much of an explanation here. Just log into the site, click the eosio.code
tab, and follow the instructions.