Can't get value from deployed contract
See original GitHub issue- I’ve asked for help in the Truffle Gitter before filing this issue.
Issue
I’m trying to use truffle on Quorum, so I followed tutorial - Building dapps for Quorum: Private Enterprise Blockchains
Steps to Reproduce
- unlike tutorial using vagrant, I use docker to build 4 nodes, but I also port forward them to 22000~22003
- truffle init
- edit
truffle-config.js
networks: {
development: {
host: "127.0.0.1", // Localhost (default: none)
port: 22000,
network_id: "*", // Any network (default: none)
gasPrice: 0,
gas: 4500000,
type: "quorum"
},
}
- create
contract/SimpleStorage.sol
and change required solc to^0.5.16
, then commandtruffle compile
- create
migrations/2_deploye_simplestorage.js
and modifyprivateFor
parameter
var SimpleStorage = artifacts.require("SimpleStorage");
module.exports = function(deployer) {
// Pass 42 to the contract as the first constructor parameter
deployer.deploy(SimpleStorage, 42, {privateFor: ["QE/RfPZh4yom6qPZOk8gfFLMeePGE+F+uG4532VinUs="]})
};
- unlock account:
geth attach --exec "personal.unlockAccount(eth.accounts[0], '', 60)" http://127.0.0.1:22000
- deploy contract:
truffle migrate
Expected Behavior
According to tutorial, I should be able to get value from contract once my truffle migrate
done
truffle console
truffle(development)> SimpleStorage.deployed().then(function(instance) { return instance.get(); })
{ [String: '42'] s: 1, e: 1, c: [ 42 ] }
Actual Results
truffle console
truffle(development)> SimpleStorage.deployed().then(function(instance) { return instance.get(); })
BN { negative: 0, words: [ 0, <1 empty item> ], length: 1, red: null }
Environment
- Operating System: Ubuntu 16.04.6 LTS
- Ethereum client: 1.8.27-stable ( host ) / 1.8.18-stable + Quorum 2.4.0 ( container )
- Truffle version (
truffle version
): v5.1.9 - node version (
node --version
): v13.6.0 - npm version (
npm --version
): 6.13.4
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:9 (6 by maintainers)
Top Results From Across the Web
solidity - Calling function from deployed contract
I have seen a function as follows. function transfer(address _to, uint _value, bytes _data, string _custom_fallback) returns (bool success) { ContractReceiver ...
Read more >Can't get value from deployed contract · Issue #5130 - GitHub
According to tutorial, I should be able to get value from contract once my truffle migrate done- `` truffle console
Read more >Can't pass value during the contract deployment in Remix
To fix this I would deploy the contract without any value argument, then create a new function so the owner can set the...
Read more >How to call another smart contract from your solidity code
1. Smart contracts are the most popular feature of the Ethereum network. Smart contracts have functions ... 2. Smart contracts are computer code,...
Read more >Interactions between Smart Contracts with Solidity - zupzup
A deployed contract always resides at an address and this address -object in ... to receive return values from the delegated call due...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @yxguo2536, could you throw an extra
.then
onto the end to convert to string?The first thing to notice is that the tutorial is probably out of date. Your expected result is a BigNumber, but Truffle now uses the BN library instead. If you convert to a string, you’ll see if you get
"42"
or not.Let us know! Thanks!
Sorry about that @yxguo2536. We’ll close this for issue maintenance for now, if you re-encounter this and can re-report it we would appreciate it!