区块链12-区块链去中心化应用开发5-DAPP实战-使用truffle创建项目

mkdir pet_shop
cd pet_shop

truffle init

创建文件pet_shop,安装,用vscode打开

下载vscode高亮插件后,因为我用的solidity0.5.1,报错

Source file requires different compiler version (current compiler is 0.7.0+commit.9e61f92b.Emscripten.clang) - note that nightly builds are considered to be strictly less than the released version

所以需要升级到0.7.0,

pragma solidity >=0.4.22 <0.8.0;

contract Adoption {

    address[16] public adopters;

    function adopt(uint petId) public returns (uint) {
        require(petId>=0 && petId <=15);
        adopters[petId] = msg.sender;
        return petId;
    }
    function getAdopters() public view returns (address[16]) {
        return adopters;
    }
}

code:address[16]

error:Data location must be "memory" or "calldata" for return parameter in function, but none was given.

翻译:函数中返回参数的数据位置必须是“memory”或“calldata”,但是没有给出。

新版本变化。需要

标明 solidity数据位置-memory,storage和calldata,及其赋值行为。

vscode需要,高亮插件需要调到0.4版最合适

 

官方插件,设置,之前已经遇到了这种情况,换了台电脑,所以,要定期整理自己的笔记

https://marketplace.visualstudio.com/items?itemName=JuanBlanco.solidity

 

远程下载

选择远程下载时,编译器将从solc-bin信息库下载。

您需要使用工作区用户设置(当前项目)或全局用户设置(所有项目)的所需版本,更改以下用户设置,例如'latest''v0.4.3+commit.2353da71'

"solidity.compileUsingRemoteVersion" : "latest"

我用的是远程方式,各种方式优先顺序和注意,转

https://blog.csdn.net/weixin_43343144/article/details/88737834?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522160578922519724835845030%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=160578922519724835845030&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_v2~rank_v28-2-88737834.first_rank_ecpm_v3_pc_rank_v2&utm_term=vscode+solidity+%E6%8F%92%E4%BB%B6%E9%80%89%E6%8B%A9&spm=1018.2118.3001.4449

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

百战成王

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值