In my project, I have created a 3 node quorum network using quorum-maker. I am calling my smart contract method from web3js. Public transactions are working fine but private transactions are always reverted by EVM.
contract.methods.myMethod().send({ from: sendEtherAddress, gas: 3000000, privateFor: [publickey] })
Error: Transaction has been reverted by the EVM:
{
"blockHash": "0x60530ed0a29d140eb5f2303169be9faf8152966612e47acb07ba91409e28e973",
"blockNumber": 49,
"contractAddress": null,
"cumulativeGasUsed": 0,
"from": "0x9c022e6495bea1a21defa776b9266efc88452195",
"gasUsed": 0,
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"status": false,
"to": "0xb9c94f33b7bebdee128c8aab172ec9157af02977",
"transactionHash": "0x2f81869e1a43a585761997eec4447ce89b0bf9ba1c65b1db8376e26ce0bad304",
"transactionIndex": 0,
"events": {}
}
at Object.TransactionError (/Users/vivart/training/blockchain/TradeApp/server/node_modules/web3-core-helpers/src/errors.js:96:21)
at Object.TransactionRevertedWithoutReasonError (/Users/vivart/training/blockchain/TradeApp/server/node_modules/web3-core-helpers/src/errors.js:108:21)
at /Users/vivart/training/blockchain/TradeApp/server/node_modules/web3-core-method/src/index.js:482:48
at processTicksAndRejections (internal/process/task_queues.js:94:5) {
receipt: {
blockHash: '0x60530ed0a29d140eb5f2303169be9faf8152966612e47acb07ba91409e28e973',
blockNumber: 49,
contractAddress: null,
cumulativeGasUsed: 0,
from: '0x9c022e6495bea1a21defa776b9266efc88452195',
gasUsed: 0,
logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
status: false,
to: '0xb9c94f33b7bebdee128c8aab172ec9157af02977',
transactionHash: '0x2f81869e1a43a585761997eec4447ce89b0bf9ba1c65b1db8376e26ce0bad304',
transactionIndex: 0,
events: {}
}
}
Truffle v5.1.39 (core: 5.1.39) Solidity - 0.6.8 (solc-js) Node v12.14.1 Web3.js v1.2.1 Quorum Maker V2.6.2 Quorum 2.2.1
genesis.json
{
"config": {
"chainId": 18743,
"homesteadBlock": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"eip150Block": 0,
"eip155Block": 0,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip158Block": 0,
"isQuorum": true
},
"alloc": {
"0xc25909404771093ff94fdfd9b4d7de18549939dc": {
"balance": "1000000000000000000000000000"
}
},
"coinbase": "0x0000000000000000000000000000000000000000",
"difficulty": "0x0",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0xE0000000",
"nonce": "0x0",
"mixhash": "0x00000000000000000000000000000000000000647572616c65787365646c6578",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp": "0x00"
}
TradeInterface.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity >0.5.2;
interface TradeInterface {
event TradeCreated(bytes32 _tradeId, address _fromParty, address _toParty, uint _amount, uint _tradeDate);
function addTrade(bytes32 _tradeId, address _fromParty, address _toParty, uint _amount, uint _tradeDate) external;
function getTrade(bytes32 _tradeId) external view returns (address, address, uint, uint);
}
TradeImpl.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity >0.5.2;
import "./TradeInterface.sol";
contract TradeImpl is TradeInterface {
struct tradeStruct {
bytes32 tradeId;
address fromParty;
address toParty;
uint amount;
uint tradeDate;
}
mapping (bytes32 => tradeStruct) tradeList;
function addTrade(bytes32 _tradeId, address _fromParty, address _toParty, uint _amount, uint _tradeDate) override external {
tradeList[_tradeId] = tradeStruct(_tradeId,_fromParty,_toParty,_amount,_tradeDate);
emit TradeCreated(_tradeId,_fromParty,_toParty,_amount,_tradeDate);
}
function getTrade(bytes32 _tradeId) public override view returns (address, address, uint, uint) {
return (tradeList[_tradeId].toParty, tradeList[_tradeId].fromParty, tradeList[_tradeId].amount,tradeList[_tradeId].tradeDate);
}
}
Web3SEervice.js
const addTrade = async (trade) => {
const httpProvider = getHttpProvider(trade.fromParty);
const web3 = new Web3(httpProvider);
const id = await web3.eth.net.getId();
const deployedNetwork = tradeInterface.networks[id];
const accounts = await web3.eth.getAccounts();
const sendEtherAddress = accounts[0];
const tradeContract = new web3.eth.Contract(tradeInterface.abi, deployedNetwork.address);
const tradeId = web3js.utils.asciiToHex(trade.tradeId);
const fromParty = getNodeAdress(trade.fromParty);
const toParty = getNodeAdress(trade.toParty);
const date = Math.floor(new Date().getTime() / 1000);
const amount = trade.amount;
let sendParams = { from: sendEtherAddress, gas: 30000000 };
if (trade.isPrivate) {
sendParams = { from: sendEtherAddress, gas: 30000000, privateFor: [getNodePublicKey(trade.toParty)] };
}
return tradeContract.methods.addTrade(
tradeId,
fromParty,
toParty,
amount,
date
).send(sendParams);
}
truffle-config.js
development: {
host: "host-ip",
port: 22000,
network_id: "*",
gas: 0,
gasPrice: 0,
type: "quorum",
}
Node logs
sending private tx privatefrom= privatefor="[QfeDAys9MPDs2XHExtc84jKGHxZg/aj52DTh0vtA3Xc=]"
DEBUG[08-26|20:36:49.204] sent private tx privatefrom= privatefor="[QfeDAys9MPDs2XHExtc84jKGHxZg/aj52DTh0vtA3Xc=]"
INFO [08-26|20:36:49.204] Private transaction signing with QuorumPrivateTxSigner
TRACE[08-26|20:36:49.206] Pooled new future transaction hash=67ac4f…5cd1cf from=0xed9d02e382b34818e88B88a309c7fe71E65f419d to=0x9d13C6D3aFE1721BEef56B55D303B09E021E27ab
TRACE[08-26|20:36:49.206] Promoting queued transaction hash=67ac4f…5cd1cf
TRACE[08-26|20:36:49.206] Promoting queued transaction hash=67ac4f…5cd1cf
INFO [08-26|20:36:49.206] Submitted transaction fullhash=0x67ac4f260b95cfd25640a008129e0784a14905a561efcbf38039b968215cd1cf recipient=0x9d13C6D3aFE1721BEef56B55D303B
09E021E27ab
INFO [08-26|20:36:49.206] QUORUM-CHECKPOINT name=TX-CREATED tx=0x67ac4f260b95cfd25640a008129e0784a14905a561efcbf38039b968215cd1cf to=0x9d13C6D3aFE17
21BEef56B55D303B09E021E27ab
DEBUG[08-26|20:36:49.206] Served eth_sendTransaction conn=92.23.215.88:51084 reqid=5 t=242.809845ms
TRACE[08-26|20:36:49.206] Broadcast transaction hash=67ac4f…5cd1cf recipients=2
INFO [08-26|20:36:49.207] VM returned with error err="VM in read-only mode. Mutating opcode prohibited"
INFO [08-26|20:36:49.207] QUORUM-CHECKPOINT name=TX-COMPLETED tx=0x67ac4f260b95cfd25640a008129e0784a14905a561efcbf38039b968215cd1cf time=356.044µs
INFO [08-26|20:36:49.207] Generated next block block num=6 num txes=1
INFO [08-26|20:36:49.207] 🔨 Mined block number=6 hash=fb6478e7 elapsed=904.157µs
TRACE[08-26|20:36:49.208] Broadcast transactions id=995dbe18829f1aff conn=inbound count=1
TRACE[08-26|20:36:49.209] Broadcast transactions id=c39143f98d04e97b conn=inbound count=1
INFO [08-26|20:36:49.211] QUORUM-CHECKPOINT name=TX-ACCEPTED tx=0x67ac4f260b95cfd25640a008129e0784a14905a561efcbf38039b968215cd1cf
INFO [08-26|20:36:49.211] VM returned with error err="VM in read-only mode. Mutating opcode prohibited"
DEBUG[08-26|20:36:49.211] Persisted trie from memory database nodes=0 size=0.00B time=5.073µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
DEBUG[08-26|20:36:49.212] Inserted new block number=6 hash=fb6478…8b9fd7 uncles=0 txs=1 gas=0 elapsed=1.073ms root=b99f0b…c6bc74
INFO [08-26|20:36:49.212] Imported new chain segment blocks=1 txs=1 mgas=0.000 elapsed=1.206ms mgasps=0.000 number=6 hash=fb6478…8b9fd7 dirty=11.60KiB
INFO [08-26|20:36:49.212] QUORUM-CHECKPOINT name=BLOCK-CREATED block=fb6478e7fe918af400c5967d9e44e4e5324c9065f4dfbed52c407ecaed8b9fd7
INFO [08-26|20:36:49.212] persisted the latest applied index index=10
DEBUG[08-26|20:36:49.212] Reinjecting stale transactions count=0
TRACE[08-26|20:36:49.212] Removed old pending transaction hash=67ac4f…5cd1cf
INFO [08-26|20:36:49.212] Not minting a new block since there are no pending transactions