Single word (bytes32) storage for EVM contracts
npm install wordbase> Single word (bytes32) storage for EVM contracts
Install with npm
``sh`
$ npm i wordbase --save
`js
//instantiation
let wordbase = web3.eth.contract(wordbaseAbi).at(wordbaseAddress)
//Simple set/get
wordbase.set(['path', 'to', 'value'], myValue)
wordbase.get(['path', 'to', 'value']) //mValue
//Multi-set (set multiple values in a single transaction)
// 1. ['productsCount'] = 2
// 2. ['product', 0, 'name'] => 'Lemonade'
// 3. ['product', 0, 'price'] => 100
// 4. ['product', 1, 'name'] => 'Cookie'
// 5. ['product', 1, 'price'] => 200
wordbase.set(
[
'productsCount',
'product', 0, 'name',
'product', 0, 'price',
'product', 1, 'name',
'product', 1, 'price'
], [
1, //length of fields in #1
3, //length of fields in #2
3, //length of fields in #3
3, //length of fields in #4
3 //length of fields in #5
], [
2,
'Lemonade',
100,
'Cookie',
200
]
)
wordbase.get(
[
'productsCount',
'product', 0, 'name',
'product', 0, 'price',
'product', 1, 'name',
'product', 1, 'price'
], [
1, //length of fields in #1
3, //length of fields in #2
3, //length of fields in #3
3, //length of fields in #4
3 //length of fields in #5
]
)
// [2, 'Lemonade', 100, 'Cookie', 200]
`
Install dev dependencies:
`sh``
$ npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Copyright © 2016 []()
Licensed under the MIT license.
*
_This file was generated by readme-generator on November 06, 2016._