日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

以太坊测试链环境node.js版本

發(fā)布時(shí)間:2024/4/17 53 豆豆
生活随笔 收集整理的這篇文章主要介紹了 以太坊测试链环境node.js版本 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

為什么80%的碼農(nóng)都做不了架構(gòu)師?>>> ??

MAC升級(jí)Nodejs和Npm到最新版
第一步,先查看本機(jī)node.js版本:

node -v

第二步,清除node.js的cache:

sudo npm cache clean -f

第三步,安裝 n 工具,這個(gè)工具是專門用來管理node.js版本的,別懷疑這個(gè)工具的名字,是他是他就是他,他的名字就是 "n"

sudo npm install -g n

第四步,安裝最新版本的node.js

sudo n stable

第五步,再次查看本機(jī)的node.js版本:

node -v

第六步,更新npm到最新版:

$ sudo npm install npm@latest -g

第七步,驗(yàn)證

node -v
npm -v

--------------------------------------------------

部署ERC20智能合約

pragma solidity ^0.4.16;

interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; }

contract TokenERC20 {
? ? //合約地址0xf6482ba598a1a94d82cffefbc21997ba225f2007
? ? //10000,"YanBing3000","YanBing"
? ? // Public variables of the token令牌的公共變量
? ? string public name;
? ? string public symbol;
? ? uint8 public decimals = 18;
? ? //
? ? uint256 public totalSupply;

? ? // This creates an array with all balances這將創(chuàng)建一個(gè)包含所有余額的數(shù)組
? ? mapping (address => uint256) public balanceOf;
? ? mapping (address => mapping (address => uint256)) public allowance;

? ? // This generates a public event on the blockchain that will notify clients這將在區(qū)塊鏈上生成將通知客戶的公共事件
? ? event Transfer(address indexed from, address indexed to, uint256 value);

? ? // This generates a public event on the blockchain that will notify clients
? ? event Approval(address indexed _owner, address indexed _spender, uint256 _value);

? ? // This notifies clients about the amount burnt這會(huì)通知客戶有關(guān)燒毀的金額
? ? event Burn(address indexed from, uint256 value);

? ? /**
? ? ?* Constructor function構(gòu)造函數(shù)
? ? ?*
? ? ?* Initializes contract with initial supply tokens to the creator of the contract將初始供應(yīng)代幣的合同初始化為合同的創(chuàng)建者
? ? ?*/
? ? function TokenERC20(
? ? ? ? uint256 initialSupply,
? ? ? ? string tokenName,
? ? ? ? string tokenSymbol
? ? ) public {
? ? ? ? totalSupply = initialSupply * 10 ** uint256(decimals); ?// 使用小數(shù)量更新總供應(yīng)量
? ? ? ? balanceOf[msg.sender] = totalSupply; ? ? ? ? ? ? ? ?// 為創(chuàng)建者提供所有初始令牌
? ? ? ? name = tokenName; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? // 設(shè)置名稱以用于顯示目的
? ? ? ? symbol = tokenSymbol; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? // Set the symbol for display purposes
? ? }

? ? /**
? ? ?* Internal transfer, only can be called by this contract內(nèi)部轉(zhuǎn)移,只能由本合同調(diào)用
? ? ?*/
? ? function _transfer(address _from, address _to, uint _value) internal {
? ? ? ? // Prevent transfer to 0x0 address. Use burn() instead防止轉(zhuǎn)移到0x0地址。請(qǐng)改用burn()
? ? ? ? require(_to != 0x0);
? ? ? ? // Check if the sender has enough
? ? ? ? require(balanceOf[_from] >= _value);
? ? ? ? // Check for overflows
? ? ? ? require(balanceOf[_to] + _value >= balanceOf[_to]);
? ? ? ? // Save this for an assertion in the future
? ? ? ? uint previousBalances = balanceOf[_from] + balanceOf[_to];
? ? ? ? // Subtract from the sender
? ? ? ? balanceOf[_from] -= _value;
? ? ? ? // Add the same to the recipient
? ? ? ? balanceOf[_to] += _value;
? ? ? ? emit Transfer(_from, _to, _value);
? ? ? ? // Asserts are used to use static analysis to find bugs in your code. They should never fail
? ? ? ? assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
? ? }

? ? /**
? ? ?* Transfer tokens
? ? ?*
? ? ?* Send `_value` tokens to `_to` from your account
? ? ?*
? ? ?* @param _to The address of the recipient
? ? ?* @param _value the amount to send
? ? ?*/
? ? function transfer(address _to, uint256 _value) public returns (bool success) {
? ? ? ? _transfer(msg.sender, _to, _value);
? ? ? ? return true;
? ? }

? ? /**
? ? ?* Transfer tokens from other address
? ? ?*
? ? ?* Send `_value` tokens to `_to` on behalf of `_from`
? ? ?*
? ? ?* @param _from The address of the sender
? ? ?* @param _to The address of the recipient
? ? ?* @param _value the amount to send
? ? ?*/
? ? function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
? ? ? ? require(_value <= allowance[_from][msg.sender]); ? ? // Check allowance
? ? ? ? allowance[_from][msg.sender] -= _value;
? ? ? ? _transfer(_from, _to, _value);
? ? ? ? return true;
? ? }

? ? /**
? ? ?* 為其他地址設(shè)置津貼
? ? ?* 授權(quán)花費(fèi)的地址
? ? ?* 他們可以花費(fèi)的最大金額
? ? ?*/
? ? function approve(address _spender, uint256 _value) public
? ? returns (bool success) {
? ? ? ? allowance[msg.sender][_spender] = _value;
? ? ? ? emit Approval(msg.sender, _spender, _value);
? ? ? ? return true;
? ? }

? ? /**
? ? ?* ?為其他地址設(shè)置津貼并通知
? ? ?* @param _spender The address authorized to spend 授權(quán)花費(fèi)的地址
? ? ?* @param _value the max amount they can spend 他們可以花費(fèi)的最大金額
? ? ?* @param _extraData some extra information to send to the approved contract 一些額外的信息發(fā)送到批準(zhǔn)的合同
? ? ?*/
? ? function approveAndCall(address _spender, uint256 _value, bytes _extraData)
? ? public
? ? returns (bool success) {
? ? ? ? tokenRecipient spender = tokenRecipient(_spender);
? ? ? ? if (approve(_spender, _value)) {
? ? ? ? ? ? spender.receiveApproval(msg.sender, _value, this, _extraData);
? ? ? ? ? ? return true;
? ? ? ? }
? ? }

? ? /**
? ? ?* Destroy tokens 銷毀令牌
? ? ?* 來自系統(tǒng)的令牌不可逆轉(zhuǎn)
? ? ?* 燒錢的金額
? ? ?*/
? ? function burn(uint256 _value) public returns (bool success) {
? ? ? ? require(balanceOf[msg.sender] >= _value); ? // 檢查發(fā)件人是否有足夠的
? ? ? ? balanceOf[msg.sender] -= _value; ? ? ? ? ? ?// Subtract from the sender
? ? ? ? totalSupply -= _value; ? ? ? ? ? ? ? ? ? ? ?// Updates totalSupply
? ? ? ? emit Burn(msg.sender, _value);
? ? ? ? return true;
? ? }

? ? /**
? ? ?* Destroy tokens from other account 從其他帳戶銷毀令牌
? ? ?*/
? ? function burnFrom(address _from, uint256 _value) public returns (bool success) {
? ? ? ? require(balanceOf[_from] >= _value); ? ? ? ? ? ? ? ?// Check if the targeted balance is enough
? ? ? ? require(_value <= allowance[_from][msg.sender]); ? ?// Check allowance
? ? ? ? balanceOf[_from] -= _value; ? ? ? ? ? ? ? ? ? ? ? ? // Subtract from the targeted balance
? ? ? ? allowance[_from][msg.sender] -= _value; ? ? ? ? ? ? // Subtract from the sender's allowance
? ? ? ? totalSupply -= _value; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?// Update totalSupply
? ? ? ? emit Burn(_from, _value);
? ? ? ? return true;
? ? }
}

--------------------------------------------------

啟動(dòng)node.js項(xiàng)目

mac終端

$ cd /Users/shijun/Desktop/nodejsWorkspace

$ git clone http://www.github.com/peopleName/projectName

WebStorm命令行

$ npm install

$ npm install koa
$ node index.js

訪問 http://localhost:3000

--------------------------------------------------

保存你的私鑰(發(fā)行者) 123456
0x1f5dacd2dc047570c6d068d5c6502a80df9f45a8b4c98fa11a692fa98dc8a1fc
UTC--2018-11-23T08_53_33.601Z--2e729a99eB5ee1f791B0FbDdcaa38A5d7E7a56D7
/Users/shijun/Desktop/word/membersheep/項(xiàng)目/sheepCoin/UTC--2018-11-23T08_53_33.601Z--2e729a99eB5ee1f791B0FbDdcaa38A5d7E7a56D7

保存你的私鑰 123456
需要在metamask中Add Token,Token的合約地址是:0xf6482ba598a1a94d82cffefbc21997ba225f2007
0x07a19997045edd19959e5628e02e0bc4d49b67e34c8ccefef0dc7e6a39921e77
UTC--2018-11-23T09_19_22.461Z--12D7A6ef0CAD3397f7937529413104Fc7a5eEBD7
/Users/shijun/Desktop/word/membersheep/項(xiàng)目/sheepCoin/UTC--2018-11-23T09_19_22.461Z--12D7A6ef0CAD3397f7937529413104Fc7a5eEBD7

轉(zhuǎn)載于:https://my.oschina.net/duojin/blog/2934650

總結(jié)

以上是生活随笔為你收集整理的以太坊测试链环境node.js版本的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。