wordbase
v0.3.0
Published
Single word (bytes32) storage for EVM contracts
Downloads
5
Readme
wordbase
Single word (bytes32) storage for EVM contracts
Install
Install with npm
$ npm i wordbase --save
Usage
Wordbase.sol
//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]
Running tests
Install dev dependencies:
$ npm i -d && npm test
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
License
Copyright © 2016 Licensed under the MIT license.
This file was generated by readme-generator on November 06, 2016.