I'm new on Ethereum. I'm trying to deploy my first smart contract in my private blockchain but my function always returns 0. I wrote the simple Smart Contract:
pragma solidity^0.5.0;
contract helloNumber {
int256 internal thisNumber;
constructor() public {
thisNumber = 4;
}
function showNumber() external pure returns (int256) {
return 4;
}
}
I generated Abi and BIN with solc
solcjs --bin helloNumber.sol
solcjs --bin helloNumber.sol
result Bin
60806040523480156100115760006000fd5b505b600460006000508190909055505b610026565b6090806100346000396000f3fe608060405234801560105760006000fd5b5060043610602c5760003560e01c806376dad22314603257602c565b60006000fd5b6038604e565b6040518082815260200191505060405180910390f35b6000600490506058565b9056fea265627a7a7231582090f812ea4d2db2a047f1e42576b9cd85f3c0bef7e9392797864143a00ce269c664736f6c634300050b0032
result ABI:
[{"constant":true,"inputs":[],"name":"showNumber","outputs":[{"internalType":"int256","name":"","type":"int256"}],"payable":false,"stateMutability":"pure","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"}]
in my shell conneted to my private blockchain:
var contract = eth.contract(ABI)
var bytecode = '0xBIN'
var deploy = {from:eth.coinbase, data:bytecode, gas: 2000000}
var object= contract .new(deploy)
object.address //returns the hashcode of smart contract on private blockchain.
object.showNumber() **//returns always 0.**
Thanks a lot in advance for your help and sorry if it's a silly question but I'new in Ethereum. what am I doing wrong?