NFT质押挖矿DAPP系统开发详情(现成案例搭建)

简介: 智能合约代码

现在我们来开始编写第一个智能合约代码,solidity代码如下:

p`js
ragma solidity ^0.4.2;
contract hello {

string greeting;

function hello(string _greeting) public {
    greeting = _greeting;
}

function say() constant public returns (string) {
    return greeting;
}

}

在编写完成代码,IDE进行编译时会出现错误,注意要选择正确的编译器版本,如图:
简单解释下,我们定义了一个名为hello的合约,在合约初始化时保存了一个字符串(我们会传入hello world),每次调用say返回字符串。
把这段代码写(拷贝)到Browser-Solidity,如果没有错误,点击Details获取部署代码,如:
部署合约
Browser-Solidity生成的代码,拷贝到编辑器里修改后的代码如下:

var _greeting = "Hello World";
var helloContract = web3.eth.contract([{"constant":true,"inputs":[],"name":"say","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function","stateMutability":"view"},{"inputs":[{"name":"_greeting","type":"string"}],"type":"constructor","payable":true,"stateMutability":"payable"}]);
var hello = helloContract.new(
_greeting,
{

 from: web3.eth.accounts[2], 
 data: '0x6060604052604051610250380380610250833981016040528080518201919060200150505b8060006000509080519060200190828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10607157805160ff1916838001178555609f565b82800160010185558215609f579182015b82811115609e5782518260005055916020019190600101906082565b5b50905060c6919060aa565b8082111560c2576000818150600090555060010160aa565b5090565b50505b50610178806100d86000396000f360606040526000357c010000000000000000000000000000000000000000000000000000000090048063954ab4b21461003c57610037565b610002565b346100025761004e60048050506100bc565b60405180806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600302600f01f150905090810190601f1680156100ae5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b602060405190810160405280600081526020015060006000508054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156101695780601f1061013e57610100808354040283529160200191610169565b820191906000526020600020905b81548152906001019060200180831161014c57829003601f168201915b50505050509050610175565b9056', 
 gas: '4700000'

}, function (e, contract){

console.log(e, contract);
if (typeof contract.address !== 'undefined') {
     console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
}

})

相关文章
|
6月前
|
安全 JavaScript 前端开发
质押理财dapp系统开发功能详细/步骤需求/方案项目/源码指南
The development of a pledge wealth management DApp system involves knowledge in various aspects such as blockchain technology, smart contracts, front-end development, and security. The following are the detailed steps for developing a pledge wealth management DApp system
|
6月前
|
算法 大数据 分布式数据库
DAPP质押模式系统开发项目方案|DAPP合约开发案例
区块链技术是一种分布式数据库技术,它是由多个节点构成的去中心化网络
|
安全 Go
dapp丨defi代币合约系统开发详情说明丨案例分析丨需求设计丨成熟案例丨源码平台
Before developing the DApp pledge mining system, it is necessary to clarify the entire development process. Firstly, determine requirements and functional planning, including user interface design, contract writing, etc. Secondly, design the system architecture to determine the relationships and dat
|
区块链 数据库 数据安全/隐私保护
IPPswap代币合约开发案例版丨IPPswap代币合约系统开发详细程序/规则玩法/方案介绍/源码平台
 Pledged mining refers to holding a certain amount of digital currency and locking it onto the blockchain network to obtain corresponding mining rewards.Pledge refers to locking a certain amount of digital currency in a blockchain network to prove one's support and participation in the network.
|
6月前
|
安全 区块链
dapp/defi智能合约质押分红系统开发详细功能/案例步骤/需求逻辑/源码指南
Developing a DApp/DeFi smart contract staking dividend system involves multiple technical and functional requirements. The following are possible detailed development steps and functional requirements for your reference
|
6月前
|
存储 安全 区块链
DAPP质押代币项目系统开发/技术分析/源码搭建
Web3.0技术栈中,去信任的交互协议和平台、分布式存储、隐私计算是生态必须率先发展完备的核心技术
|
11月前
|
存储 安全 区块链
dapp合约系统开发|dapp分红系统开发案例分析
“去中心化”是区块链的典型特征之一,其使用分布式储存与算力,整个网络节点的权利与义务相同
|
12月前
|
区块链
DAPP流动性质押项目系统开发指南方案
智能合约是一种以代码形式存在的合约,旨在在去中心化网络上执行和实施。
|
存储 区块链 UED
DAPP流动性质押系统开发方案与详情|DAPP合约案例
区块链的另一个固有挑战是其确定性。确定性本质意味着一旦一个块被添加到区块链中,它就无法更改,并且任何智能合约执行的结果都是可预测的和一致的。
|
存储 前端开发 安全
defi丨dapp丨ippswap代币发行合约项目系统开发规则方案及开发案例源码
  智能合约是一种基于区块链技术的自动执行代码。它是一种可以在区块链上自动执行、不可篡改的协议。智能合约能够有效地执行预定义好的规则和条款,并且在满足预设条件的情况下自动执行。这种合约大大降低了交易成本,提高了交易的可靠性。