Created
July 14, 2018 00:27
-
-
Save SaifRehman/ccae311db000bace5f8d80fcb5c526d7 to your computer and use it in GitHub Desktop.
app.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Web3 = require('web3') | |
var web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:5000')) | |
web3.eth.defaultAccount = web3.eth.accounts[0] | |
console.log(web3.eth.accounts[0]) | |
var ABI = [ | |
{ | |
"constant": false, | |
"inputs": [ | |
{ | |
"name": "_value", | |
"type": "string" | |
} | |
], | |
"name": "set", | |
"outputs": [], | |
"payable": false, | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, | |
{ | |
"constant": true, | |
"inputs": [], | |
"name": "get", | |
"outputs": [ | |
{ | |
"name": "", | |
"type": "string" | |
} | |
], | |
"payable": false, | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"constant": true, | |
"inputs": [], | |
"name": "value", | |
"outputs": [ | |
{ | |
"name": "", | |
"type": "string" | |
} | |
], | |
"payable": false, | |
"stateMutability": "view", | |
"type": "function" | |
} | |
] | |
var ByteCode = "608060405234801561001057600080fd5b50610410806100206000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680633fa4f2451461005c5780634ed3885e146100ec5780636d4ce63c14610155575b600080fd5b34801561006857600080fd5b506100716101e5565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100b1578082015181840152602081019050610096565b50505050905090810190601f1680156100de5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156100f857600080fd5b50610153600480360381019080803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610283565b005b34801561016157600080fd5b5061016a61029d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101aa57808201518184015260208101905061018f565b50505050905090810190601f1680156101d75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b60008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561027b5780601f106102505761010080835404028352916020019161027b565b820191906000526020600020905b81548152906001019060200180831161025e57829003601f168201915b505050505081565b806000908051906020019061029992919061033f565b5050565b606060008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103355780601f1061030a57610100808354040283529160200191610335565b820191906000526020600020905b81548152906001019060200180831161031857829003601f168201915b5050505050905090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061038057805160ff19168380011785556103ae565b828001600101855582156103ae579182015b828111156103ad578251825591602001919060010190610392565b5b5090506103bb91906103bf565b5090565b6103e191905b808211156103dd5760008160009055506001016103c5565b5090565b905600a165627a7a72305820c362e846f942c5b7cf0e0b88a2bb844b4341bc801b48a7267c7dbdb4745e6e210029", | |
Contract = web3.eth.contract(ABI) | |
deployedContract = Contract.new(['a','b'], {data: ByteCode}) | |
myContract = Contract.at(web3.eth.getTransactionReceipt(deployedContract.transactionHash).ContractAddress) | |
console.log('mycontract',myContract) | |
myContract.set("saif") | |
console.log(myContract.get()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment