当前位置:网站首页>Summary of solid problems
Summary of solid problems
2022-04-23 08:45:00 【ling1998】
1、 Query contract account balance (address(this).balance) Report errors
In their own Geth When querying the contract account balance on the private chain, there is an error , But use Remix Of Javascript VM Normal during execution , Use the test network Goerli It's normal , Be able to view the contract balance .
(1) Execute function
// Query contract account balance , Use view Modifier
function getContractAccountBalance() public view returns (uint256){
return address(this).balance; //this Is the object of this contract
}
(2) error message
call to functionModifier.getContractAccountBalancecall to functionModifier.getContractAccountBalance errored: Internal JSON-RPC error. { "code": -32000, "message": "invalid opcode: SELFBALANCE" }
As shown in the figure :
(3) Solution
stay genesis.json Medium config increase ”istanbulBlock“ Set up , As shown below :
{
"config": {
"chainId": 1422,
"homesteadBlock": 0,
"eip150Block": 0,
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock":0,
"ethash": {}
},
"difficulty": "1",
"gasLimit": "8000000",
"alloc": {
"7df9a875a174b3bc565e6424a0050ebc1b2d1d82": { "balance": "300000" },
"f41c74c9ae680c1aa78f42e5647a62f353b7bdde": { "balance": "400000" }
}
}
Close all nodes , Rerun init Command enables the new chain configuration . Tested , You can query the contract account balance normally
May refer to :blockchain - Geth private network return error "invalid opcode: SELFBALANCE" when executing a simple contract - Stack Overflow
Or official website :Private Networks | Go Ethereum
版权声明
本文为[ling1998]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230842141867.html
边栏推荐
猜你喜欢

经典题目刷一刷

K210学习笔记(二) K210与STM32进行串口通信

JVM工具之Arthas使用

OneFlow学习笔记:从Functor到OpExprInterpreter

Study notes of deep learning (8)

2022-04-22 OpenEBS云原生存储

Virtual online exhibition - Online VR exhibition hall realizes 24h immersive exhibition viewing

After a circle, I sorted out this set of interview questions..

Redis Desktop Manager for Mac(Redis可视化工具)

洋桃电子STM32物联网入门30步笔记四、工程编译和下载
随机推荐
Consensus Token:web3.0生态流量的超级入口
【IndexOf】【lastIndexOf】【split】【substring】用法详解
LaTeX数学公式
1099 建立二叉搜索树 (30 分)
请提前布局 Star Trek突破链游全新玩法,市场热度持续高涨
RCC introduction of Hal Library
After a circle, I sorted out this set of interview questions..
Redis Desktop Manager for Mac(Redis可视化工具)
OneFlow學習筆記:從Functor到OpExprInterpreter
Noyer électronique stm32 Introduction à l'Internet des objets 30 étapes notes I. différences entre la Bibliothèque Hal et la Bibliothèque standard
mycat配置
K210学习笔记(二) K210与STM32进行串口通信
What is RPC
Complete binary search tree (30 points)
DOM learning notes - traverse all element nodes of the page
洋桃电子STM32物联网入门30步笔记二、CubeIDE下载、安装、汉化、设置
2021李宏毅机器学习之Adaptive Learning Rate
GUI编程简介 swing
00后最关注的职业:公务员排第二,第一是?
Knowledge points and problem solutions related to information collection