action

action module

action object

Usage:use in js contract of fibos

1
2
var js_code = `exports.hi = v => console.error(action.is_account(action.account), action.is_account("notexists"));`;
fibos.setcodeSync(name, 0, 0, fibos.compileCode(js_code));

Static function

is_account

check whether the account exist

1
action.is_account(name);

Parameter Usage:

Results:

Example:

1
2
3
4
exports.hi = v => {
if (action.is_account(account)) console.notice("account exists");
else console.error("account notexists")
};

has_recipient

after action executed,the account names name will receive a notification

1
action.has_recipient(name);

Parameter Usage:

Results:

Example:

1
2
3
4
exports.hi = v => {
if (action.has_recipient(receiver)) console.notice("action received")
else console.error("action not received");
};

require_recipient

add specific account to notification list

1
action.require_recipient(name);

Parameter Usage:

Example:

1
2
3
4
5
6
7
exports.hi = v => {
action.require_recipient(action.receiver);
};

exports.on_hi = v => {
console.log(action.receiver, action.account , v)
};

Note:A notification message sent by one contract to another is a message received by the contract, including code, action, and parameters.

has_auth

Verify that the action requires authorization for a specific account

1
action.has_auth(name);

Parameter Usage:

Results:

Example:

1
2
3
4
exports.hi = v => {
if (action.has_auth(account));
console.notice("action be authed");
};

require_auth

Add a specific account and corresponding permissions to the action’s authorization list, and an exception is returned if the addition fails

1
action.require_auth(name, permission);

Parameter Usage:

Example:

1
2
3
4
exports.hi = v => {
action.require_auth(account);
console.notice("auth success");
};

Static Property

name

action name

Type: String

Example:

1
2
3
exports.hi = v => {
console.log(action.name)
};

account

action sender account name

Type: String

Example:

1
2
3
exports.hi = v => {
console.log(action.account)
};

receiver

action receiver

Type: String

Example:

1
2
3
exports.hi = v => {
console.log(action.receiver)
};

publication_time

Return the millisecond number of block produced since 1970.01.01 0pm 0min 0sec (UTC)

Type: Number

Example:

1
2
3
exports.hi = v => {
console.log(action.publication_time)
};

authorization

Executing action requires all the accounts in array authorized

Type: Array

Example:

1
2
3
exports.hi = v => {
console.log(action.authorization)
};