ethereum - 使用solidity创建合约但不执行
问题描述
I'am building a local blockchain using etherium.I wrote a smart contract "Hello" that allows to display a phrase. when I execute truffle.compile an error occurs: No visibility specified. Did you intend to add "public"?
pragma solidity ^0.4.15;
contract Hello{
string public message;
function Hello() {
message = "Hello, World : This is a Solidity Smart Contract on the Private Ethereum Blockchain ";
}
}
编译你的合同...
Compiling ./contracts/Hello.sol
Compiling ./contracts/Migrations.sol
/home/mohamed/Projects/Stage/Truffle/contracts/Hello.sol:1:1: SyntaxError: Source file requires different compiler version (current compiler is 0.5.0+commit.1d4f565a.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version
pragma solidity ^0.4.15;
^----------------------^
,/home/mohamed/Projects/Stage/Truffle/contracts/Hello.sol:4:4: SyntaxError: No visibility specified. Did you intend to add "public"?
function Hello1() {
^ (Relevant source part starts here and spans across multiple lines).
Error: Truffle is currently using solc 0.5.0, but one or more of your contracts specify "pragma solidity ^0.4.15".
Please update your truffle config or pragma statement(s).
(See https://truffleframework.com/docs/truffle/reference/configuration#compiler-configuration for information on
configuring Truffle to use a specific solc compiler version.)
Compilation failed. See above.
Truffle v5.0.12 (core: 5.0.12)
节点 v8.9.4
解决方案
推荐阅读
- python - 获得 Deeplab 对小/欠平衡类的更严格的分割结果
- mysql - UnhandledPromiseRejectionWarning:错误:未找到 Category#products 的实体元数据
- memory-management - 运行时错误:CUDA 内存不足。试图分配...但内存是空的
- java - 需要将 Arraylist 从 java 程序传递给 R 脚本作为参数
- amazon-web-services - 是否可以在 AWS Application Load Balancer 中启用 x-forward
- python - ModuleNotFoundError:没有名为“keras”的模块无法导入 keras
- javascript - Bootstrap 3 datetimepicker - MinTime 和 MaxTime
- bash - bash函数内的花括号
- react-native - 反应原生避免滚动视图/平面列表在键盘打开时缩小
- google-cloud-platform - Google API Gateway:在标头中提供 API 密钥