I have a rpi 3 where I wrote a script in JS( a socket),which takes data from a python script. So I have this var “data”(which is an array of string) in JS and I want to save it in ethereum blockchain. I know I need web3.js library to interface with ethereum node and I’ve already installed npm and node.js So my question is…how I pass the value contained in “data” in a smart contract,which stored them?

Further information: Till now I am using testRPC as test network and Truffle to try a contract.

This is the JS socket enter image description here

1 Answer 1


Using strings is expensive I'd avoid them if it is posible.

If all your strings are less that 32 bytes, you can use bytes32 instead of string that way you can pass them in an array:

function methodName(bytes32[] data) public {
    // Resto of the code

If you really need to use string you can concatenate all your data in a single string using a predefined separator, and split them inside your solidity code. You can use a string library like solidity-stringutils.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.