- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 Solidity 新手,这是我正在测试和重新混合的代码
browser/Untitled.sol:1:1: : 源文件未指定所需的编译器版本!考虑添加“pragma Solidity ^0.4.12契约(Contract) C {^跨越多行。
希望有人能指导一下。
contract C {
function bytes32ToString(bytes32 x) constant returns (string) {
bytes memory bytesString = new bytes(32);
uint charCount = 0;
for (uint j = 0; j < 32; j++) {
byte char = byte(bytes32(uint(x) * 2 ** (8 * j)));
if (char != 0) {
bytesString[charCount] = char;
charCount++;
}
}
bytes memory bytesStringTrimmed = new bytes(charCount);
for (j = 0; j < charCount; j++) {
bytesStringTrimmed[j] = bytesString[j];
}
return string(bytesStringTrimmed);
}
function bytes32ArrayToString(bytes32[] data) returns (string) {
bytes memory bytesString = new bytes(data.length * 32);
uint urlLength;
for (uint i=0; i<data.length; i++) {
for (uint j=0; j<32; j++) {
byte char = byte(bytes32(uint(data[i]) * 2 ** (8 * j)));
if (char != 0) {
bytesString[urlLength] = char;
urlLength += 1;
}
}
}
bytes memory bytesStringTrimmed = new bytes(urlLength);
for (i=0; i<urlLength; i++) {
bytesStringTrimmed[i] = bytesString[i];
}
return string(bytesStringTrimmed);
} }
最佳答案
在源文件的最顶部包含版本编译指示以消除警告。
pragma solidity ^0.4.0;
contract MyContract {
}
Version Pragma
Source files can (and should) be annotated with a so-called version pragma to reject being compiled with future compiler versions that might introduce incompatible changes. We try to keep such changes to an absolute minimum and especially introduce changes in a way that changes in semantics will also require changes in the syntax, but this is of course not always possible. Because of that, it is always a good idea to read through the changelog at least for releases that contain breaking changes, those releases will always have versions of the form
0.x.0
orx.0.0
.The version pragma is used as follows:
pragma solidity ^0.4.0;
Such a source file will not compile with a compiler earlier than version 0.4.0 and it will also not work on a compiler starting from version 0.5.0 (this second condition is added by using ^). The idea behind this is that there will be no breaking changes until version 0.5.0, so we can always be sure that our code will compile the way we intended it to. We do not fix the exact version of the compiler, so that bugfix releases are still possible.
关于ethereum - Solidity Remix 简单问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44946625/
当我点击 remix.ethereum.org 下的创建时,我不明白智能合约的实际去向。例如,如果我选择 Injected Web3,这应该会将合约发布到 ropsten 测试网上,对吧?但是我怎样才
我通过下面的推荐安装了ganache-cli npm install -g ganache-cli 我已经下载了文件 ganache-1.1.0-beta.0-x86_64.AppImage 当我点
如果我在 ETH 和 RSK 网络中导入相同的私钥,则帐户相同但大小写不同。为什么是这样?这个可以吗? 最佳答案 大写作为校验和,涉及以下标准 SLIP-0044 EIP-155 EIP-1191 有
我们落后于代理。代理已设置。 早些时候,我们运行以下命令并成功安装了以太坊。 sudo apt-get install software-properties-common sudo add-apt-
请找到我的 golang 规范 GOOS=linux GOARCH=amd64 go build github.com/ethereum/go-ethereum/crypto/secp256k1: b
我正在尝试使用 Puppeth(如 Péter Szilágyi demoed in Ethereum devcon three 2017)设置私有(private)以太坊测试网络。我在 macboo
我是一步一步做的: Git 克隆 go-ethereum 项目到我的本地 PC。它位于D:\GOPATH\src\github.com\ethereum\go-ethereum。这是源代码去以太坊 注
我正在尝试生成 personal_sign在 Golang 中就像在 ethers.js 中实现的那样。 Similar question但最终使用了常规 sign过个人sign_implementa
我正在尝试安装 Istanbul-tools 以运行 IBFT 以太坊网络,如本教程所示 https://medium.com/getamis/istanbul-bft-ibft-c2758b7fe6
我想降低我的 ERC-721A 合约的部署成本。 一般来说; 扁平化智能合约是否有助于降低其成本? 目前我正在使用 ethers.js's contractFactory.deploy method带
我有契约(Contract)要求输入 bytes32,所以我需要将地址转换为 bytes32,但在 web3 中没有看到这个方法。 最佳答案 以太坊地址为 20 个字节,因此您将十六进制地址转换为字节
我想与将在调用时部署其他契约(Contract)的功能签订契约(Contract)。可能吗?有什么想法吗? 最佳答案 这是部署合约的合约示例。 https://ethereum.stackexchan
由于与以太坊创建智能合约涉及以太币用户,因此重新填充所有用户的以太币对公司而言成本高昂。因此,假设一家公司决定通过以太坊网络发行一种代币,而该代币代表一种新货币。每次用户向其他人发送代币时,代币的原始
我想知道提交智能合约调用的确切效果。例如,如果我在 uniswap 上将 USDC 兑换成 ETH。 对于交易,我们有 eth_call,对于合约有类似的东西吗?这需要适用于任意复杂的交互,基本上是我
如果我有这样的功能: function sendToAuthor (uint tokenId) public payable{ //here I want to get some ether fr
我正在试验以太坊。我已经按照网站上的说明成功设置了一个私有(private)测试网。但是,我无法添加来自不同机器的对等点。在我创建的任何节点上,admin.nodeInfo.NodeUrl 参数都是未
我在 Remix 上做了一笔交易,花费了 199093 gas。在撰写本文时,天然气价格为 7.2 Gwei(0.031 美元)from here ethgas station 如果我想计算我应该为这
根据 web3.eth.sendTransaction 的文档和 eth_sendTransaction 的文档: 交易对象可以包含一个可选的data参数,它应该是一个String,包含: 要么是包含
是否有任何方法可以在 Solidity 中实现一个集合,以检查元素是否存在,平均 O(1)?我一直在考虑使用没有值的映射对象,这是否比使用数组并迭代以查找元素更快? 最佳答案 是的,就速度而言,您最好
在OpenZeppelin ERC20实现中,有一个_transfer方法: function _transfer( address sender, address recipient
我是一名优秀的程序员,十分优秀!