Problem: All method calls to my deployed contract return null
Versions:
Geth: 1.9.9-unstable Git Commit: c2d65d34d5c6f27b8d1a52280964023a3eefd66e
solc: Version: 0.5.13+commit.5b0b510c.Linux.g++
web3: [email protected]
An ERC20 contract takes four arguments in the constructor. My constructor is defined like this:
string public name;
string public symbol;
address public admin; // For debugging
uint8 public decimals;
uint256 public totalSupply;
event Deployed(address indexed _admin, uint256 indexed _totalSupply, string _name); // For debugging
constructor(string memory _tokenName, string memory _tokenSymbol, uint8 _decimals, uint256 _initialSupply) public {
name = _tokenName;
symbol = _tokenSymbol;
decimals = _decimals;
totalSupply = _initialSupply;
admin = msg.sender; // For debugging
balanceOf[msg.sender] = totalSupply;
emit Deployed(msg.sender, totalSupply, _tokenName); // For debugging
}
I use this JavaScript code to deploy an ERC20 contract to my private test net.
var contractObject = web3.eth.contract(<ABI definition>);
var submittedContract = contractObject.new('DKK', 'DKK', 1, 1000000, {data:'<bin>', gas: 20000000}, <callback>);
Calling eth.getTransactionReceipt(submittedContract.transactionHash);
returns (only relevant fields included):
eth.getTransactionReceipt("0xeb512f29ef2789b592b19acbbb78f8c6be6f7eaed96460c239e0a5d8c20e1dd2");
{
contractAddress: "0xe23cfc0248b83a4bce8f9701a86e08e9cf9c59f4",
...
logs: [{
...
data: "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003444b4b0000000000000000000000000000000000000000000000000000000000",
...
topics: ["0xf0bbe877a87290e236ea898bbce0d78d6ac7d54d62e32744b129798a2669e39b", "0x00000000000000000000000075bf9b4280b7963ddb1e9198b3aca5b1e02dcf57", "0x00000000000000000000000000000000000000000000000000000000000f4240"],
...
}],
status: "0x1",
...
}
The status
field should indicate that there were no errors, but I am not sure that my constructor values are set correctly. Can you see that from the topics
field?
When I then call contractObject.at("0xe23cfc0248b83a4bce8f9701a86e08e9cf9c59f4").totalSupply();
, it returns 0. But it should return 1000000.
await
in that last line of code (or some other means of handling thePromise
object returned from the call tototalSupply
).topics[2] == 0xf4240 == 1000000
.dep.admin().then(console.log);
gives meTypeError: 'then' is not a function at <anonymous>:1:1
andawait dep.admin();
(anonymous): Line 1:7 Unexpected identifier (and 1 more errors)