Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- contract UserBasic {
- bytes32 test;
- function getBytes(uint _value) constant returns(bytes32) {
- return test;
- }
- function setBytes(bytes32 _bytes) {
- test = _bytes;
- }
- }
- {
- blockHash: "0x891546aa79223a100234098953f6c103140c910c64f1aaa1091eef37014c231b",
- blockNumber: 945,
- from: "0xc5756ccc9748e1a71b60eff8367543b42a0facf1",
- gas: 90000,
- gasPrice: 18000000000,
- hash: "0x47ab0461b3202f2b15a52ae866b445c64b2d30b0ede767689c702f8f17c61765",
- input: "0xe6748da93539393563653233383730346264373632303132373064390000000000000000",
- nonce: 4,
- r: "0xfbe02d3ee427c82274e50ee2771a7e305156e8a715dd86482a38da02d2bbacaa",
- s: "0x7a30b01680c44fdf134893cf2e422afa920f8b0435b7f50190fce7df28c37e51",
- to: "0xd705ef113e0a514a1dc9b84a7badd66fe84a3d57",
- transactionIndex: 0,
- v: "0xf0a",
- value: 0
- }
- getBytes: function getBytes(contractAddress) {
- // Fetching the contract related data
- const input = fs.readFileSync('contracts/UserBasic.sol').toString();
- const output = solc.compile(input);
- const bytecode = output.contracts[':UserBasic'].bytecode;
- const abi = JSON.parse(output.contracts[':UserBasic'].interface);
- const contract = web3.eth.contract(abi).at(contractAddress);
- // Interaction with the contract
- contract.getRecords.call(2, (err, res) => {
- // Log transaction to explore
- if (err) {
- console.log(err);
- } else {
- console.log(res);
- }
- });
- },
- setBytes: function setBytes(publicAddress, contractAddress, _bytes) {
- // Fetching the contract related data
- const input = fs.readFileSync('contracts/UserBasic.sol').toString();
- const output = solc.compile(input);
- const bytecode = output.contracts[':UserBasic'].bytecode;
- const abi = JSON.parse(output.contracts[':UserBasic'].interface);
- const contract = web3.eth.contract(abi).at(contractAddress);
- // Interaction with the contract
- contract.setBytes(_bytes, {from: publicAddress}, (err, res) => {
- // Log transaction to explore
- if (err) {
- console.log(err);
- } else {
- console.log('tx: ' + res);
- }
- });
- }
- []
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement