Solidity

Parity POA 智能合約方法總是失敗

  • June 19, 2019

我已經按照parity 首頁上的教程建立了一個私有 POA 網路。我有兩個節點在 localhost:8540 和 localhost:8541 上執行。我已經將 MetaMask 連接到我的第一個節點,並且能夠在測試賬戶之間發送交易,甚至可以從 remix 部署智能合約。不幸的是,我無法從已部署的合約中呼叫函式,因為氣體估算總是失敗並且交易被探勘但執行失敗。

這是我的配置:

規範.json

{
"name": "OraclePOA",
"engine": {
   "authorityRound": {
       "params": {
           "stepDuration": "5",
           "validators" : {
               "list": [
                   "0x0038ba71301213d9508ce44fd25272d83b1c5dae",
                   "0x002e9ac8fef5ab0d0591488860562438ab154bd4"
               ]
           }
       }
   }
},
"params": {
   "gasLimitBoundDivisor": "0x400",
   "maximumExtraDataSize": "0x20",
   "minGasLimit": "0x1388",
   "networkID" : "0x2323",
   "maxCodeSize": "0x6000",
   "eip155Transition": 0,
   "validateChainIdTransition": 0,
   "eip140Transition": 0,
   "eip211Transition": 0,
   "eip214Transition": 0,
   "eip658Transition": 0
},
"genesis": {
   "seal": {
       "authorityRound": {
           "step": "0x0",
           "signature": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
       }
   },
   "difficulty": "0x100000",
   "gasLimit": "0x1000000"
},
"accounts": {
   "0x0000000000000000000000000000000000000001": { "balance": "1", "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } },
   "0x0000000000000000000000000000000000000002": { "balance": "1", "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } },
   "0x0000000000000000000000000000000000000003": { "balance": "1", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } },
   "0x0000000000000000000000000000000000000004": { "balance": "1", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } },
   "0x00d695cd9b0ff4edc8ce55b493aec495b597e235": { "balance": "10000000000000000000000" },
   "0x001ca0bb54fcc1d736ccd820f14316dedaafd772": { "balance": "10000000000000000000000" }
}
}

連接 MetaMask 的節點配置:

[parity]
chain = "oracle-spec.json"
base_path = "/myOracle/parity0"
[network]
port = 30300
[rpc]
port = 8540
apis = ["web3", "eth", "net", "personal", "parity", "parity_set", "traces", "rpc", "parity_accounts"]
[websockets]
port = 8450
[account]
password = ["authNode0.pwds"]
[mining]
engine_signer = "0x0038ba71301213d9508ce44fd25272d83b1c5dae"
reseal_on_txs = "none"
usd_per_tx = "0"

這是我的樣本契約:

pragma solidity 0.5.7;
contract Sample{
   //address of owner
   address payable owner;

   //whoever deploys contract is the owner
  constructor() public{
       owner = msg.sender;
  }

   function doSomething() external payable {
       int i = 10 + 10;
       i++;
  }
}

通過 Remix 的交易截圖

幫助將不勝感激!

我想到了。問題是solidity的編譯器版本。智能合約僅適用於低於 0.5.4 的solidity 版本。Github 上已經有 Ticket 了。欲了解更多資訊檢查:https ://github.com/paritytech/parity-ethereum/issues/10502

引用自:https://ethereum.stackexchange.com/questions/71956