Overview
This guide provides instructions to link a permission to a smart contract action.
The example uses cleos
to link a custom permission customp in the account alice to a hi action deployed to the scontract account so that the alice account's active
permission and customp permission are authorized to call the hi _action.
Before you Begin
Make sure you meet the following requirements:
-
Install the currently supported version of
cleos.
- You have an EOSIO account and access to the account's
active
private key. - You have created a custom permission. See cleos set account permission.
Command Reference
See the following reference guides for command line usage and related options:
- cleos set action permission command
link Procedure
The following step shows you how to link a permission:
- Run the following command to link alices account permission customp with the hi action deployed to the scontract account:
cleos set action permission alice scontract hi customp -p alice@active
Where
alice
= The name of the account containing the permission to link.scontract
= The name of the account which owns the smart contract.hi
= The name of the action to link to a permission.customp
= The permission used to authorize the transaction.-p alice@active
= The permission used to authorize linking the customp permission.
Example Output
executed transaction: 4eb4cf3aea232d46e0e949bc273c3f0575be5bdba7b61851ab51d927cf74a838 128 bytes 141 us
# eosio <= eosio::linkauth {"account":"alice","code":"scontract","type":"hi","requirement":"customp"}
Summary
In conclusion, by following these instructions you are able to link a permission to a smart contract action.