Skip to content

setvals.a ​

Set key values of an Uniq

Technical Behavior ​

Before setting values, the key have to be defined in factory with addkeys.a action

Only editor including owner | manager | authorized editor can update Uniq's values if the edit right is configured for them.

The key value will only store in Uniq, and will be stored as key index and key value. Key index will be referred to factory key definition list.

In key_values, key_name must be unique and existed in factory keys. key_value must match the type defined in factory keys.

If no editor is included, owner will be the editor and the editor also need to sign the contract.

No RAM payment requires for this action since it's already paid in factory level.

Action Parameters ​

The properties of this type are provided below:

Property NameC++ TypeJavaScript TypeDescription
ownernameStringOnwer of the Uniq
editoroptional<name>StringThe authorized editor of the key
token_iduint64_tNumberThe ID of the Uniq that value will be updated
key_valueskey_values_action_vecObject[]The list of key name and value for updating
memostringStringMemo

key_values_action_vec is the vector of key_values_action

key_values_action interface ​

Property NameC++ TypeJavaScript TypeDescription
key_namestringStringThe name of the key defined in factory keys.
key_valuekey_value_storeObject[]The value that will be set for the key. Value needs to match the type defined in factory keys.

key_value_store will be an array with first element is type of the value and second is the value. Here is the support list and example:

Value TypeKey Def Type stringExample
int8int8["int8", 0]
int16int16["int16", 0]
int32int32["int32", 0]
int64int64["int64", 0]
uint8uint8["uint8", 0]
uint16uint16["uint16", 0]
uint32uint32["uint32", 0]
uint64uint64["uint64", 0]
floatfloat32["float32", 0.1]
doublefloat64["float64", 0.1]
stringstring["string", "a"]

CLI - cleos ​

bash
cleos push action eosio.nft.ft setvals.a '{ "owner": "alice", "editor": null, "token_id": 8, "keys_values": [ "key_name": "keyname", "key_value": [ "uint8", 3 ] ], "memo": "set key value" }' -p alice@active

JavaScript - eosjs ​

js
await transact(
    [
        {
            account: 'eosio.nft.ft',
            name: 'setvals.a',
            authorization: [{ actor: 'alice', permission: 'active' }],
            data:  {
                owner: "alice",
                editor: null,
                token_id: 8,
                keys_values: [
                    key_name: "keyname",
                    key_value: [ "uint8", 3 ]
                ],
                "memo": "set key value"
            },
        },
    ],
    {
        blocksBehind: 3,
        expireSeconds: 30,
    }
);