createMultiData(contracts, sender, dataKeys, dataValues, currency)
Feature
Return raw operation for creating multiple data. The length of dataKeys must same with length of dataValues and contracts. (max length is 100) Note: Handler of contract also can execute the function.
Parameters
string
| string[]
contract address, // If given a string, it is automatically converted to an array filled with the same values.
string
sender,
string[]
dataKeys, (element’s max length is 200, must not contain: space / : ? # [ ] @)
string[]
dataValues, (element’s max length is 20000)
string
currency ID
Return Value
object
create-datas operation
example1. create data to each contract
const contract = "0xb2310381f7E51a69d0C4cCdbE7a6DCB3B7353192fca";
const contract2 = "0xa6283308BBedbfB8041A2Ea950A11D142A0F4FD9fca";
const sender = "0x4526f3D0EdC63D9EaeCD94D56551e0f061CFCa47fca";
const currencyId = "MCC";
const contracts = [contract, contract, contract2, contract2];
const dataKeys = ["key1", "key2", "key3", "key4"];
const dataValues = ["value1", "value2", "value3", "value4"];
const op = mitum.storage.createMultiData(contracts, sender, dataKeys, dataValues, currencyId);
console.log(op)
// output
Operation {
id: 'mitum',
fact: CreateDatasFact {
hint: Hint { s: 'mitum-storage-create-datas-operation-fact' },
token: Token { s: '2024-10-22 02:12:23.167 +0000 UTC' },
_hash: <Buffer d2 95 1b 64 ee a2 1c ed 71 18 42 1a 8a 47 63 c7 6d 91 e2 9e 65 c8 31 a4 6f fa 83 ab 99 08 b4 7c>,
sender: Address {
s: '0x4526f3D0EdC63D9EaeCD94D56551e0f061CFCa47fca',
type: 'mitum'
},
items: [
[CreateDatasItem],
[CreateDatasItem],
[CreateDatasItem],
[CreateDatasItem]
]
},
hint: Hint { s: 'mitum-storage-create-datas-operation' },
_factSigns: [],
_hash: <Buffer >
}
example2. create four data to contract (0xb2…
)
const contract = "0xb2310381f7E51a69d0C4cCdbE7a6DCB3B7353192fca";
const sender = "0x4526f3D0EdC63D9EaeCD94D56551e0f061CFCa47fca";
const currencyId = "MCC";
const contracts = contract;
const dataKeys = ["key1", "key2", "key3", "key4"];
const dataValues = ["value1", "value2", "value3", "value4"];
const op = mitum.storage.createMultiData(contract, sender, dataKeys, dataValues, currencyId);
console.log(op)
// output
Operation {
id: 'mitum',
fact: CreateDatasFact {
hint: Hint { s: 'mitum-storage-create-datas-operation-fact' },
token: Token { s: '2024-10-22 02:12:23.167 +0000 UTC' },
_hash: <Buffer d2 95 1b 64 ee a2 1c ed 71 18 42 1a 8a 47 63 c7 6d 91 e2 9e 65 c8 31 a4 6f fa 83 ab 99 08 b4 7c>,
sender: Address {
s: '0x4526f3D0EdC63D9EaeCD94D56551e0f061CFCa47fca',
type: 'mitum'
},
items: [
[CreateDatasItem],
[CreateDatasItem],
[CreateDatasItem],
[CreateDatasItem]
]
},
hint: Hint { s: 'mitum-storage-create-datas-operation' },
_factSigns: [],
_hash: <Buffer >
}
Last updated