etherlime-2-Etherlime Library API-deployer
Etherlime Library API 库API
Deployer部署者
Deployer functionality
The main functionality the deployer exposes is (obviously) the ability to deploy compiled contract.
开发者暴露的主要函数(明显)是部署编译合约的能力。
This is achieved through the deploy(contract, [libraries], [params]) function.
通过deploy(contract, [libraries], [params])函数得到这样的能力
deploy(contract, [libraries], [params])
Parameters参数:
contract- descriptor object for contract to be deployed. More details below被部署合约的描述对象,更多细节在下面libraries- key-value object containing all libraries which will be linked to the contract. 链接到合约的包含所有库的键-值对象params- the constructor params you’d need to pass on deploy (if there are any) 在部署中你需要传给合约构造函数的参数(如果需要的话)
The contract is descriptor object that needs to have at least the following three fields:
合约是至少需要下面三个字段的描述对象
contractName- the name of the contract 合约名字abi- the abi interface of the contract 合约abi接口bytecode- the compiled bytecode 编译的字节码
The easiest way to get such descriptor is to compile your solidity files via etherlime compile
最简单的得到描述者的方法是通过etherlime compile编译你的solidity文件
The libraries object should be in the following format:
文件对象应该是如下的格式:
{
libraryName0: '0xAddressOfLibrary0',
libraryName1: '0xAddressOfLibrary1'
}
If the contract to be deployed doesn’t contains any libraries, {}, undefined, null, false or 0 can be passed. For convenience we have made the deploy function to work even without this parameter passed.
如果被部署的合约没有包含任何的库,那么可以传递{}, undefined, null, false 或0给库对象。为了方便,即使没有这些参数被传递我们也可以让部署函数工作起来
Example举例说明:
Linking libraries链接库
const contractUsingQueueAndLinkedList = require('...');
const libraries = {
Queue: '0x655341AabD39a5ee0939796dF610aD685a984C53,
LinkedList: '0x619acBB5Dafc5aC340B6de4821835aF50adb29c1'
}
await deployer.deploy(contractUsingQueueAndLinkedList, libraries);
Skipping linking on contract without arguments
跳过库链接并且合约构造函数不需要参数
const contractWithoutLibraries = require('...');
await deployer.deploy(contractWithoutLibraries);
Skipping linking on contract with arguments
跳过库链接,合约构造函数需要参数
const contractWithoutLibraries = require('...');
await deployer.deploy(contractWithoutLibraries, false, param1, param2);
estimateGas(contract, [libraries], [params])估计使用的gas
Estimates the gas that this transaction is going to cost you.估计这个交易将要花费的gas
Parameters参数:
contract- descriptor object for contract to be deployed 部署的合约的描述对象libraries- key-value object containing all libraries which will be linked to the contract. 链接到合约的包含所有库的键-值对象params- the constructor params you’d need to pass on deploy (if there are any)在部署中你需要传给合约构造函数的参数(如果需要的话)
The contract is descriptor object is the same as above.
合约是和上面一样的描述对象
Example举例说明
const estimate = await deployer.estimateGas(TestContract, randomParam1, randomParam2);
// returns something like "2470692"
Deployers
InfuraPrivateKeyDeployer
InfuraPrivateKeyDeployer(privateKey, network, apiKey, [defaultOverrides])
Parameters参数:
privateKey- The private key to the deployment wallet 部署钱包的密钥network- network as found inethers.providers.networks 使用ethers.providers.networks找到的网络apiKey- your Infura API keydefaultOverrides- [Optional] object overiding the deployment settings forgasPriceandgasLimit.(可选)复写部署设置中的gasPrice和asLimit的对象
const etherlime = require('etherlime');
const TestContract = require('./TestContract.json');
const defaultConfigs = {
gasPrice: ,
gasLimit:
}
const deploy = async (network, secret) => {
const deployer = new etherlime.InfuraPrivateKeyDeployer('Your Private Key Goes Here', 'ropsten', 'Your Infura API Key', defaultConfigs);
const result = await deployer.deploy(TestContract, '0xda8a06f1c910cab18ad187be1faa2b8606c2ec86', );
}
JSONRPCPrivateKeyDeployer
JSONRPCPrivateKeyDeployer(privateKey, nodeUrl, [defaultOverrides])
Parameters参数:
privateKey- The private key to the deployment wallet部署钱包的密钥nodeUrl- the url to the node you are trying to connect (local or remote)你打算连接的节点的URL(本地或远程)defaultOverrides- [Optional] object overiding the deployment settings forgasPriceandgasLimit.(可选)复写部署设置中的gasPrice和asLimit的对象
const etherlime = require('etherlime');
const TestContract = require('./TestContract.json');
const defaultConfigs = {
gasPrice: ,
gasLimit:
}
const deploy = async (network, secret) => {
const deployer = new etherlime.JSONRPCPrivateKeyDeployer('Your Private Key Goes Here', 'http://localhost:8545/', defaultConfigs);
const result = await deployer.deploy(TestContract);
}
EtherlimeGanacheDeployer
EtherlimeGanacheDeployer([privateKey], [port], [defaultOverrides])
Parameters:
privateKey- [Optional] The private key to the deployment wallet. Defauts to the first one in the etherlime ganache(可选)部署钱包的私钥。默认为etherlime ganache中的第一个账户port- [Optional] the port you’ve ran the etherlime ganache on. Defaults to 8545.(可选)etherlime ganache的端口,默认为8545defaultOverrides- [Optional] object overiding the deployment settings forgasPriceandgasLimit.(可选)复写部署设置中的gasPrice和asLimit的对象
This deployer only works with etherlime ganache
该部署只在etherlime ganache能工作
const etherlime = require('etherlime');
const TestContract = require('./TestContract.json');
const defaultConfigs = {
gasPrice: ,
gasLimit:
}
const deploy = async (network, secret) => {
const deployer = new etherlime.EtherlimeGanacheDeployer();
const result = await deployer.deploy(TestContract);
}
etherlime-2-Etherlime Library API-deployer的更多相关文章
- Google Ajax Library API使用方法(JQuery)
Google Ajax Library API使用方法 1.传统方式: <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7. ...
- Windows api 函数全部列表 (未完成)
网上找了很久,发现没有完整版的,msdn上面有,但是不方便查阅,所以想自己整理一下:由于工程量过于庞大,希望大家共同完成.MSDN:http://msdn.microsoft.com/en-us/li ...
- Prism5.0新内容 What's New in Prism Library 5.0 for WPF(英汉对照版)
Prism 5.0 includes guidance in several new areas, resulting in new code in the Prism Library for WPF ...
- etherlime-1-Quick Start
https://etherlime.readthedocs.io/en/latest/getting-started.html Quick Start Installing全局安装 npm i -g ...
- etherlime-4-Etherlime CLI
Etherlime CLI命令行界面 Installing & Help Syntax语法 npm i -g etherlime Install the global etherlime to ...
- The .NET of Tomorrow
Ed Charbeneau(http://developer.telerik.com/featured/the-net-of-tomorrow/) Exciting times lie ahead f ...
- 资源list:Github上关于大数据的开源项目、论文等合集
Awesome Big Data A curated list of awesome big data frameworks, resources and other awesomeness. Ins ...
- robotframework笔记22
创建测试库 支持的编程语言 机器人框架本身是用写的 Python 和自然的测试 库扩展它可以使用相同的实现 语言. 运行时框架上 Jython ,图书馆也可以 实现使用 Java . 纯Python代 ...
- C++ 多继承和虚继承的内存布局(转)
转自:http://www.oschina.net/translate/cpp-virtual-inheritance 警告. 本文有点技术难度,需要读者了解C++和一些汇编语言知识. 在本文中,我们 ...
随机推荐
- mysql根据经纬度求两地距离
#1.两点距离(1.4142135623730951) ,),point(,)); select st_distance(point (120.10591, 30.30163),point(120.1 ...
- JVM垃圾回收器之G1(Garbage First)--new
相比CMS收集器有两个显著的改进: (1). G1收集器是基于“标记-整理”算法实现的收集器,不会产生空间碎片 (2). 它可以精确地控制停顿,能让使用者明确指定在一个长度为M毫秒的时间片段内,消耗在 ...
- 基于Udp的五子棋对战游戏
引言 本文主要讲述在局域网内,使用c#基于Udp协议编写一个对战的五子棋游戏.主要从Udp的使用.游戏的绘制.对战的逻辑这三个部分来讲解. 开发环境:vs2013,.Net4.0,在文章的末尾提供源代 ...
- 在AE二次开发中出“正试图在 OS 加载程序锁内执行托管代码。不要尝试在 DllMain 或映像初始化函数内运行托管代码,这样做会导致应用程序挂起。”异常解决方案
今天的一个项目总用到了AE的开发组件,也就是ESRI公司提供的一系列的开发包(组件)都是以dll(动态链接库的形式)然后今天在调试的时候却出现了“正试图在 OS 加载程序锁内执行托管代码.不要尝试在 ...
- BZOJ1935: [Shoi2007]Tree 园丁的烦恼(树状数组 二维数点)
题意 题目链接 Sol 二维数点板子题 首先把询问拆成四个矩形 然后离散化+树状数组统计就可以了 // luogu-judger-enable-o2 #include<bits/stdc++.h ...
- css的元素表现
块级元素和行内元素的表现: 块级元素:块级元素和父元素的宽度一致,默认情况下就是和body的宽度一样,也可以说和浏览器窗口的宽度一致,致使同一行不能再放下另外的元素,所以块级元素表现为独占一行. 块级 ...
- 浏览器根对象window之事件
1. [事件]动画 onanimationstart onanimationend onanimationiteration onwebkitanimationend onwebkitanimatio ...
- ArcGIS10+:ArcGIS version not specified. You must call RuntimeManager.Bind before creating any ArcGIS
ArcGIS10+版本,使用VS创建一个简单的AE应用程序,然后拖放一个toolbar.LicenseControl以及MapControl控件. 接着编译应用程序,编译成功. 然后单击F5运行程序, ...
- MySQL的索引与优化
写在前面:索引对查询的速度有着至关重要的影响,理解索引也是进行数据库性能调优的起点.考虑如下情况,假设数据库中一个表有10^6条记录,DBMS的页面大小为4K,并存储100条记录.如果没有索引,查询将 ...
- Ubuntu 安装python
1. wget http://mirrors.sohu.com/python/3.6.0/Python-3.6.0.tar.xz wget https://www.python.org/ftp/pyt ...