赞
踩
- //环境
- Truffle v5.5.21 (core: 5.5.21)
- Ganache v7.2.0
- Solidity v0.5.16 (solc-js)
- Node v14.17.3
- Web3.js v1.7.4
1.建个文件夹 truffle_demo
mkdir truffle_demo
2.进入文件夹内,执行init命令,会搭建基本框架出来
truffle init
3.在contracts下新建一个文件,比如DataDemo.sol
- // SPDX-License-Identifier: MIT
- pragma solidity >=0.4.22 <0.9.0;
- contract DataDemo{
- string public returnTest;
- //set方法
- function setData(string memory str ) public payable {
- returnTest = str;
- }
- //get方法
- function getData() public view returns (string memory) {
- return returnTest;
- }
- }
4.修改migrations/1_initial_migration.js
- const Migrations = artifacts.require("Migrations");
- var DataDemo = artifacts.require("./DataDemo.sol");
-
- module.exports = function(deployer) {
- deployer.deploy(Migrations);
- d
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。