Skip to content

addkeys.a ​

Add key pairs for Uniq factory

Technical Behavior ​

The manager of an Uniq factory should be able to add one or more key pairs at the factory level at any time, which means key pairs at the factory level can change over time. When that happens, all Uniqs minted from that factory should be able to use all key pairs no matter when minted.

Key name has to be unique.

Key type is the data type of the value, and it has to be in the supported list from keytypes table.

edit_rights define which permission can edit the value including manager | owner | authorized editor | user group.

editor this is authorized editor mentioned above, and it required to have at least one account here.

default_value has to match the key type, like integer if it's uint or int. Also, if the type is an array, total element cannot exceed the limit from keytypes action. In case of the string or string[], total character cannot exceed the limit.

Factory RAM payment will be calculated based on the usage of key_defs which include some fixed RAM usage and usage which will determined by the key type. And the payment is non-refundable.

Uniq RAM payment for the new key will be calculated based on how many Uniq are already minted from factory. And this payment will be put into factory on-chain RAM vault, which will be refunded when Uniq is burn.

Action Parameters ​

The properties of this type are provided below:

Property NameC++ TypeJavaScript TypeDescription
factory_iduint64_tNumberID of the Uniq factory for which key pairs will be added.
key_defsstd::vector<key_def_action>Object[]The definition of the key including name, type, edit right, editors and default values.
memostringStringMemo

key_def_action interface ​

Property NameC++ TypeJavaScript TypeDescription
namestringStringThe name of the key, needs to be unique.
typestringStringThe type of the value stored in the key.
edit_rightsuint8_tNumberBitmask, determines who can edit the key including asset manager, owner, authorized editor or user group.
editorsstd::vector<name>String[]The editor if authorized editor is set.
default_valuestd::optional<key_value_store>ObjectThe default value of the key which needs to match with type.

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"]

edit_rights bitmask breakdown ​

ValueDescription
0x01Manager can edit
0x02Owner can edit
0x04Authorized editor can edit (used with 0x08)
0x08Editor is a user group

CLI - cleos ​

bash
cleos push action eosio.nft.ft addkeys.a '{ "factory_id": 10, "key_defs": [ { "name": "id1", "type": "int8", "edit_rights": 8, "editors": [ "bob" ], "default_value": [ "int8", -8 ] }, { "name": "id2", "type": "int16", "edit_rights": 8, "editors": [ "bob" ], "default_value": [ "int16", 16 ] }, { "name": "id3", "type": "int32", "edit_rights": 8, "editors": [ "bob" ], "default_value": [ "int32", -32 ] }, { "name": "id4", "type": "int64", "edit_rights": 8, "editors": [ "bob" ], "default_value": [ "int64", 64 ] }, { "name": "id5", "type": "uint8", "edit_rights": 8, "editors": [ "bob" ], "default_value": [ "uint8", 8 ] }, { "name": "id6", "type": "uint16", "edit_rights": 8, "editors": [ "bob" ], "default_value": [ "uint16", 16 ] }, { "name": "id7", "type": "uint32", "edit_rights": 8, "editors": [ "bob" ], "default_value": [ "uint32", 32 ] }, { "name": "id8", "type": "uint64", "edit_rights": 8, "editors": [ "bob" ], "default_value": [ "uint64", 64 ] }, { "name": "id9", "type": "float32", "edit_rights": 8, "editors": [ "bob" ], "default_value": [ "float32", -1.32 ] }, { "name": "id10", "type": "float64", "edit_rights": 8, "editors": [ "bob" ], "default_value": [ "float64", 1.64 ] }, { "name": "id11", "type": "string", "edit_rights": 8, "editors": [ "bob" ], "default_value": [ "string", "abc" ] } ], "memo": "add new key pairs" }' -p alice@active

JavaScript - eosjs ​

js
await transact(
    [
        {
            account: 'eosio.nft.ft',
            name: 'addkeys.a',
            authorization: [{ actor: 'alice', permission: 'active' }],
            data: {
                factory_id: 10,
                key_defs: [
                    {
                        name: "id1",
                        type: "int8",
                        edit_rights: 8,
                        editors: [ "bob" ],
                        default_value: [ "int8", -8 ]
                    },
                    {
                        name: "id2",
                        type: "int16",
                        edit_rights: 8,
                        editors: [ "bob" ],
                        default_value: [ "int16", 16 ]
                    },
                    {
                        name: "id3",
                        type: "int32",
                        edit_rights: 8,
                        editors: [ "bob" ],
                        default_value: [ "int32", -32 ]
                    },
                    {
                        name: "id4",
                        type: "int64",
                        edit_rights: 8,
                        editors: [ "bob" ],
                        default_value: [ "int64", 64 ]
                    },
                    {
                        name: "id5",
                        type: "uint8",
                        edit_rights: 8,
                        editors: [ "bob" ],
                        default_value: [ "uint8", 8 ]
                    },
                    {
                        name: "id6",
                        type: "uint16",
                        edit_rights: 8,
                        editors: [ "bob" ],
                        default_value: [ "uint16", 16 ]
                    },
                    {
                        name: "id7",
                        type: "uint32",
                        edit_rights: 8,
                        editors: [ "bob" ],
                        default_value: [ "uint32", 32 ]
                    },
                    {
                        name: "id8",
                        type: "uint64",
                        edit_rights: 8,
                        editors: [ "bob" ],
                        default_value: [ "uint64", 64 ]
                    },
                    {
                        name: "id9",
                        type: "float32",
                        edit_rights: 8,
                        editors: [ "bob" ],
                        default_value: [ "float32", -1.32 ]
                    },
                    {
                        name: "id10",
                        type: "float64",
                        edit_rights: 8,
                        editors: [ "bob" ],
                        default_value: [ "float64", 1.64 ]
                    },
                    {
                        name: "id11",
                        type: "string",
                        edit_rights: 8,
                        editors: [ "bob" ],
                        default_value: [ "string", "abc" ]
                    }
                ],
                "memo": "add new key pairs"
            },
        },
    ],
    {
        blocksBehind: 3,
        expireSeconds: 30,
    }
);