browser/ballot.sol:61:13: Warning: Using contract member "balance" inherited from the address type is deprecated. Convert the contract to "address" type to access the member. require(this.balance >= 1000000000000000);
“将合同转换为地址”类型是什么意思?我怎么知道this的地址?
我通过Remix浏览器在0.4.21的Solidity
我在混音中收到警告。这是什么意思?我是不是漏掉了什么?下面是演示它的简单代码:
pragma solidity ^0.4.20;
contract HelloWorld
{
string hello = "Hello World";
function sayHello() returns (string)
{
return hello;
}
}
现在我收到警告:
browser/HelloWorld.sol:6:5: Warning: Function state mutability can be restricted to view
function sayHel
在关于自毁的可靠的官方文件中,写着:
如果您想要停用您的合同,则应该通过更改导致所有函数恢复的内部状态来禁用它们。
参考资料:https://solidity.readthedocs.io/en/latest/introduction-to-smart-contracts.html#deactivate-and-self-destruct
有人能解释我什么意思吗?
该代码是否足以销毁合同?:
function kill() public {
if (msg.sender == owner)
// only allow this action if the account sen
我是个生疏的新手。下面是我遇到的代码片段:-
pragma solidity ^0.4.0; contract C { //1
function f(uint len) { // value passed to len = 7 //2
uint[] memory a = new uint[](7); //3
bytes memory b = ne
我正在尝试安装和使用由ConsenSys编写的python解析器
我继续得到以下错误
File "<stdin>", line 1, in <module> File "/home/seed/.local/lib/python3.5/site-packages/python-solidity-parser/solidity_parser/__init__.py", line 1, in <module> from .parser import parse_file, parse, objectify, visit
我试图编译这段代码:
contract C {
struct s {
string chan;
string content;
}
s[] x = new s[](0);
}
它给我带来了一个令人困惑的编译器错误:
Unimplemented feature:
/solidity/libsolidity/codegen/ArrayUtils.cpp(237): Throw in function solidity::frontend::ArrayUtils::copyArrayToStorage(const solidity::front
我试图在VScode中运行一个简单的代码。
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
import "hardhat/console.sol";
contract WavePortal {
constructor() {
console.log("Yo yo, I am a contract and I am smart");
}
}
当我试图编译代码时,它显示了以下错误
这是我的launch.json
{
// Use Intel
我试图从源代码构建solidity编译器(solc),源代码是从实心储存库克隆的。我遵循了坚实性文件中的指令,但在执行时遇到了一个错误:cmake .. && make。cmake错误如下:
[ 42%] Building CXX object libsolidity/CMakeFiles/solidity.dir/formal/Z3Interface.cpp.o
/my/path/to/solidity/libsolidity/formal/Z3Interface.cpp: In member function ‘z3::expr dev::solidity::smt::Z3
编译失败了。
vi contracts/MyCoin.sol:
pragma solidity ^0.4.18;
import 'zeppelin-solidity/contracts/token/ERC20/StandardToken.sol';
contract MyCoin is StandardToken {
string public name = "MyCoin";
string public symbol = "MC";
uint public decimals = 2;
uint public INITIAL_
我正在尝试安装和使用,pip3安装没有给出错误,但当我尝试导入模块时,它显示
File "<stdin>", line 1, in <module>
File "/home/seed/.local/lib/python3.5/site-packages/python-solidity-parser/solidity_parser/__init__.py", line 1, in <module>
from .parser import parse_file, parse, objectify, visit
Fi
我从这个源http://solidity.readthedocs.io/en/latest/contracts.html#events上读到关于使用事件的文章,我使用了一个简单的乘契约:
contract test1{
uint a;
event event_res(string msg,uint x);
function test1(){
a = 1;
}
function multiply (uint b){
a = a*b;
event_res("the value aft
我有一个可靠的项目,文件如下
pragma solidity ^0.5.0;
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
当我试图编译时,在未安装的库上会出现错误。
npx hardhat compile
Error HH411: The library openzeppelin-solidity,
imported from contracts/....sol, is not installed.
Try installing it using npm.
我试图通过硬帽子编译两个不同的契约,使用两个不同的编译器版本。我不断地发现错误:
Error HH606: The project cannot be compiled, see reasons below.
The Solidity version pragma statement in these files doesn't match any of the configured compilers in your config. Change the pragma or configure additional compiler versions in your hardhat
我安装了Openzeppelin框架并创建了一个简单的令牌simple。
pragma solidity ^0.4.24;
import "node_modules/openzeppelin-solidity/contracts/token/ERC20/MintableToken.sol";
contract SToken is MintableToken {
string public constant name = "SS Token";
string public constant symbol = "SKS";