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, {}undefinednullfalse or 0 can be passed. For convenience we have made the deploy function to work even without this parameter passed.

如果被部署的合约没有包含任何的库,那么可以传递{}undefinednullfalse0给库对象。为了方便,即使没有这些参数被传递我们也可以让部署函数工作起来

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 in ethers.providers.networks 使用ethers.providers.networks找到的网络
  • apiKey - your Infura API key
  • defaultOverrides - [Optional] object overiding the deployment settings for gasPrice and gasLimit.(可选)复写部署设置中的 gasPriceasLimit的对象
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 for gasPrice and gasLimit.(可选)复写部署设置中的 gasPriceasLimit的对象
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的端口,默认为8545
  • defaultOverrides - [Optional] object overiding the deployment settings for gasPrice and gasLimit.(可选)复写部署设置中的 gasPriceasLimit的对象

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的更多相关文章

  1. Google Ajax Library API使用方法(JQuery)

    Google Ajax Library API使用方法 1.传统方式: <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7. ...

  2. Windows api 函数全部列表 (未完成)

    网上找了很久,发现没有完整版的,msdn上面有,但是不方便查阅,所以想自己整理一下:由于工程量过于庞大,希望大家共同完成.MSDN:http://msdn.microsoft.com/en-us/li ...

  3. 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 ...

  4. etherlime-1-Quick Start

    https://etherlime.readthedocs.io/en/latest/getting-started.html Quick Start Installing全局安装 npm i -g ...

  5. etherlime-4-Etherlime CLI

    Etherlime CLI命令行界面 Installing & Help Syntax语法 npm i -g etherlime Install the global etherlime to ...

  6. The .NET of Tomorrow

    Ed Charbeneau(http://developer.telerik.com/featured/the-net-of-tomorrow/) Exciting times lie ahead f ...

  7. 资源list:Github上关于大数据的开源项目、论文等合集

    Awesome Big Data A curated list of awesome big data frameworks, resources and other awesomeness. Ins ...

  8. robotframework笔记22

    创建测试库 支持的编程语言 机器人框架本身是用写的 Python 和自然的测试 库扩展它可以使用相同的实现 语言. 运行时框架上 Jython ,图书馆也可以 实现使用 Java . 纯Python代 ...

  9. C++ 多继承和虚继承的内存布局(转)

    转自:http://www.oschina.net/translate/cpp-virtual-inheritance 警告. 本文有点技术难度,需要读者了解C++和一些汇编语言知识. 在本文中,我们 ...

随机推荐

  1. sql判断某个字段是否为空

    判断sql某个字段是否为NULL public function dataNull($id){ $sql = 'SELECT * FROM `vvt_company_funcs_user` WHERE ...

  2. asp.ne如何使用javascript去验证客户端信息,如果验证成功则送往服务器端处理,否则在客户端提示用户(不返回到服务器端处理)

    一.问题 在网站一般都有很多地方需要用户去填写一些信息,然后用户点击提交,将信息送往后台储存到数据库中.在这一个过程我以前做法直接在button的click事件中来判断用户输入的数据是否完整和合法,虽 ...

  3. R包下载的一些小问题

    install.packages(c("matrixStats", "Hmisc", "splines", "foreach&qu ...

  4. FineReport中如何用JavaScript解决控件值刷新不及时

    我们经常利用按钮进行一些页面值的处理工作,但是默认的逻辑造成,每次新填报的值,需要点击下空白区域或是执行某个其他操作才可以被正确读取,那么我们如何处理呢? 例:当我们用常规取值的时候,虽然B3单元格录 ...

  5. Java 简化版学生管理系统(IO版)

    Student management system   学生管理系统IO版 详细知识点可参考一下几篇文章 常用API Java 之ArrayList集合及应用 Java 之IO流及应用 Compreh ...

  6. Progress数据库配置与应用

    创建database 开始->程序->OpenEdge,选择:Desktop,进行database创建. 选择创建一个空database或直接copy一个demo的database,我们选 ...

  7. 使用jar命令打jar/war包、创建可执行jar包、运行jar包、及批处理脚本编写

    jar 命令 jar 是一个jar.exe可执行命令,即可以生成jar文件,也可以生成war文件   使用示例:jar -cvf ../xxx.jar *  -c   create,创建新的归档文档 ...

  8. 软工读书笔记 week 7 ——《构建之法》

    总时长近两周的结对项目终于算是结束了,马上要重新开启团队项目.于是这几天决定对<构建之法>一书中与团队项目及需求分析有关的章节进行重点阅读,希望能够从中得到启发,并运用到接下来的团队项目中 ...

  9. LeetCode 题解之Add Two Numbers II

    1.题目描述 2.分析 首先将链表翻转,然后做加法. 最后将结果链表翻转. 3.代码 ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) { Lis ...

  10. leetCode题解之Product of Array Except Self

    1.题目描述 2.题目分析 每个元素对应的积应该是 它 前面的每个元素的积,和后面的每个元素的积 3.代码 vector<int> productExceptSelf(vector< ...