truffle
truffle copied to clipboard
Support XinFin blockchain
The address prefix of XinFin blockchain is xdc, not 0x. So the truffle report below error when deploy contract:
Error: Given address "xdc0000000000000000000000000000000000000000" is not a valid Ethereum address.
at Object.toChecksumAddress (<DIR>/node_modules/truffle/build/webpack:/node_modules/web3-utils/lib/index.js:263:1)
at Method.outputBlockFormatter (<DIR>/node_modules/truffle/build/webpack:/node_modules/web3-core-helpers/lib/formatters.js:284:1)
at Method.web3.eth.getBlock.method.outputFormatter (<DIR>/node_modules/truffle/build/webpack:/packages/interface-adapter/dist/shim/overloads/ethereum.js:38:1)
at Method.formatOutput (<DIR>/node_modules/truffle/build/webpack:/node_modules/web3-eth/node_modules/web3-core-method/lib/index.js:148:1)
at sendTxCallback (<DIR>/node_modules/truffle/build/webpack:/node_modules/web3-eth/node_modules/web3-core-method/lib/index.js:531:1)
at <DIR>/node_modules/truffle/build/webpack:/node_modules/web3-core-requestmanager/lib/index.js:305:1
at <DIR>/node_modules/web3-provider-engine/index.js:234:9
at <DIR>/node_modules/async/internal/once.js:12:16
at replenish (<DIR>/node_modules/async/internal/eachOfLimit.js:61:25)
at <DIR>/node_modules/async/internal/eachOfLimit.js:71:9
at eachLimit (<DIR>/node_modules/async/eachLimit.js:43:36)
at <DIR>/node_modules/async/internal/doLimit.js:9:16
at end (<DIR>/node_modules/web3-provider-engine/index.js:211:5)
at Request._callback (<DIR>/node_modules/web3-provider-engine/subproviders/rpc.js:72:5)
at Request.self.callback (<DIR>/node_modules/request/request.js:185:22)
at Request.emit (node:events:527:28)
at Request.<anonymous> (<DIR>/node_modules/request/request.js:1154:10)
at Request.emit (node:events:527:28)
at IncomingMessage.<anonymous> (<DIR>/node_modules/request/request.js:1076:12)
at Object.onceWrapper (node:events:641:28)
at IncomingMessage.emit (node:events:539:35)
at endReadableNT (node:internal/streams/readable:1345:12)
Truffle v5.5.29 (core: 5.5.29)
Node v16.16.0
JSSONRPC request:
curl -X POST https://rpc.apothem.network/ -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x0", false],"id":1}'
JSSONRPC response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"difficulty": "0x1",
"extraData": "0x00000000000000000000000000000000000000000000000000000000000000003ea0a3555f9b1de983572bff6444aeb1899ec58c4f7900282f3d371d585ab1361205b0940ab1789c942a5885a8844ee5587c8ac5e371fc39ffe618960000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x47b760",
"gasUsed": "0x0",
"hash": "0xbdea512b4f12ff1135ec92c00dc047ffb93890c2ea1aa0eefe9b013d80640075",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"miner": "xdc0000000000000000000000000000000000000000",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"nonce": "0x0000000000000000",
"number": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"penalties": "0x",
"receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"size": "0x29d",
"stateRoot": "0x8e3faa435358e7027e68989700c2edd281c87518f82c127e8523df46c41c160f",
"timestamp": "0x5d02164f",
"totalDifficulty": "0x1",
"transactions": [],
"transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"uncles": [],
"validator": "0x",
"validators": "0x"
}
}
The miner is xdc0000000000000000000000000000000000000000, not 0x0000000000000000000000000000000000000000.
It's necessarily a little difficult to handle such violations of the JSON RPC standard. Is it possible that XinFin could change its behavior here to be conformant? I might suggest filing an issue with them...
Great! In the threads above @XinFinOrg shared their ethereum json rpc compatible endpoints, so nothing to do here I guess.