title | description | category | published | order |
---|---|---|---|---|
Action (Method) |
Provides functionality for generating an Antelope Action instance from a Contract instance. |
ContractKit |
true |
2 |
The action
method is a convenient way to generate an Antelope Action instance from a Contract instance. Actions can be created using this method and then be passed to the SessionKit transact method to be executed on chain.
The action
method is available on any Contract instance. Calling this method will return a single action based on the arguments provided.
const action = tokenContract.action(
"transfer", // or Name.from('transfer')
{
from: "foo",
to: "bar",
quantity: "1.0000 EOS",
}
)
The action
method takes two arguments:
name
: The name of the action as defined in the ABI. Can be a string or an instance of Name.data
: The data to be used within the action as an object. This will vary depending on the contract action that is used.
The third parameter is optional and can be used to specify the following option:
authorization
: An array of PermissionLevel objects that will be used to authorize the action. When this option is not specified, placeholder values will be used, which will be resolved to the current signer of the transaction if the action is performed.
const action = tokenContract.action(
"transfer",
{
from: "foo",
to: "bar",
quantity: "1.0000 EOS",
},
{
authorization: [{ actor: "foo", permission: "active" }],
}
)
The action
method returns an instance of Action.