truffle

solidity测试用例实战

梦想与她 提交于 2020-03-26 10:17:20
3 月,跳不动了?>>> Truffle开发框架提供了以太坊智能合约测试的两种方法:区块链级别的Solidity测试和DApp级别的JavaScript测试。在这个教程中,我们将介绍这两种以太坊智能合约测试方法的用途、区别与应用场景,并通过一个具体的示例来学习如何综合利用Solitiy测试用例和JavaScript测试用例对以太坊智能 合约进行单元测试和集成测试。 七种开发语言的以太坊教程: Java | Php | Python | .Net / C# | Golang | Node.JS | Flutter / Dart 1、以太坊智能合约测试概述 作为软件开发者,我们都知道要让代码正常运行,测试是非常重要的一个环节。基于区块链的去中心化软件也不例外,而且由于区块链的不可修改特性,测试对于区块链软件来说就更重要了。 总体上来说有两种类型的软件测试:单元测试和集成测试。单元测试聚焦于单个函数的测试,而集成测试的目标则是确保各部分代码组合起来也可以按期望的方式运行。 Truffle是应用最广的以太坊智能合约与DApp开发框架,它提供了两种用于测试以太坊智能合约的方法:Solidity测试和JavaScript测试。问题是,我们应该选择哪一种方法? 答案是都需要。 用Solidity编写智能合约的测试用例让我们可以在区块链层级进行测试。这种测试用例可以调用合约方法

企业以太坊Besu入门教程【原Pantheon】

此生再无相见时 提交于 2020-02-27 12:20:38
Besu是Hyperledger中的企业以太坊产品,其最大优势在于兼容以太坊主网。本教程介绍如何使用Hyperledger Besu快速启动一个企业以太坊网络并利用JSON RPC进行数据查询和交易提交,以及如何使用Truffle开发企业以太坊DApp并使用内置的工具进行数据调试和运维监控。 1、启动企业以太坊网络 以太坊教程推荐: Dapp入门 | 电商Dapp实战 | Token实战 | Php对接 | Java对接 | Python对接 | C#对接 | Dart对接 首先克隆Besu的quickstart仓库的源代码: git clone https://github.com/PegaSysEng/besu-quickstart.git 然后进入besu-quickstart目录,执行如下命令构建besu的docker镜像: ./run.sh 上面的命令会构建docker镜像并启动4个容器来模拟一个包含6个besu节点的企业以太坊网络。当脚本执行完成后,你可以看到如下输出信息: ************************************* Besu Quickstart <version> ************************************* List endpoints and services --------------------

区块链开发需要学习什么技术

老子叫甜甜 提交于 2020-01-09 17:32:34
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 区块链是当前的热点方向之一,未来区块链领域的机会也会比较多,如果想进入区块链领域,需要根据自身的知识结构和资源整合能力来考虑切入点。 如果想通过技术手段进入区块链领域,可以分为三个步骤,其一是掌握编程语言;其二是掌握算法设计;其三是掌握某一区块链的开源产品。编程语言的选择还是比较多的,目前采用Java语言比较常见,很多开源框架也是基于Java语言实现的。算法基础对于从事区块链开发是比较重要的,因为区块链技术本身就是以算法为基础来实现的,所以从事区块链开发对于数学的要求还是相对比较高的。 区块链开发——工具与框架篇 Ethers.js是针对以太坊钱包功能完整实现的工具包,其API文档十分详尽。 Truffle用于开发合约工程的框架,是一套本地集成开发环境和编译测试调试工具。在Truffle提供的开发环境里,整合了前端实例化合约的方法,可以很便捷的调用合约功能。另外还有各种box支持开箱即用,整合了前端应用调用合约工程的途径。 Geth是一个以太坊客户端,用Go语言编写,它是目前最常用的以太坊客户端,有着丰富的API,不过没有可视化操作界面。可以与Mist配合来进行以太坊智能合约的开发调试。 Solc是以太坊官方提供的Solidity编译工具。

How to deploy truffle contract to dev network when using inheritance?

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-05 07:36:09
问题 I have been attempting to deploy a contract using the Truffle framework, I have recently been testing these contracts on the development network. My contract was very large and when I attempted to deploy it to a test net, I was instructed to split it up so that the contract wouldn't exceed the gas limit. Although, bearing in mind this contract did deploy onto the development network with the default gas limit. So I took out parts of the contract and derived another contract from the base and

How to deploy truffle contract to dev network when using inheritance?

自闭症网瘾萝莉.ら 提交于 2020-01-05 07:35:35
问题 I have been attempting to deploy a contract using the Truffle framework, I have recently been testing these contracts on the development network. My contract was very large and when I attempted to deploy it to a test net, I was instructed to split it up so that the contract wouldn't exceed the gas limit. Although, bearing in mind this contract did deploy onto the development network with the default gas limit. So I took out parts of the contract and derived another contract from the base and

npm error “Keccak bindings compilation fail.” while installing truffle

拜拜、爱过 提交于 2020-01-04 02:57:06
问题 I tried to install Truffle, but then I got this error: $ npm install -g truffle C:\Users\dany.vandermeij\AppData\Roaming\npm\truffle -> C:\Users\dany.vandermeij\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js > keccak@1.4.0 install C:\Users\dany.vandermeij\AppData\Roaming\npm\node_modules\truffle\node_modules\keccak > npm run rebuild || echo "Keccak bindings compilation fail. Pure JS implementation will be used." > keccak@1.4.0 rebuild C:\Users\dany.vandermeij\AppData\Roaming

Quorum Ethereum Truffle) Error: Number can only safely store up to 53 bits

一世执手 提交于 2019-12-23 04:14:16
问题 I am actually learning smart contract programming on ethereum and I work with truffle. Right now I am making this tutorial here: https://truffleframework.com/tutorials/building-dapps-for-quorum-private-enterprise-blockchains Where you learn how to create a dapp with quorum. But now I have a problem. I did everything exactly as described, but when I do: truffle migrate I get this error here: $ truffle migrate ⚠️ Important ⚠️ If you're using an HDWalletProvider, it must be Web3 1.0 enabled or

Truffle command not found after installation

霸气de小男生 提交于 2019-12-22 03:49:11
问题 I installed truffle through npm with the following: sudo npm install -g truffle but when I run truffle list on the console it just gives me bash: truffle: command not found 回答1: Please make sure you have the latest version of npm and node installed. I had the same issue, I updated npm and node to latest version and it worked. npm install -g truffle works. 回答2: I had a similar problem. I ran npm i -g truffle and then when I tried to run truffle init I got an error: zsh: command not found:

Is it secure to run public ethereum node?

萝らか妹 提交于 2019-12-21 21:22:20
问题 I'm creating my first Ethereum contract with truffle. I want the web application to be usable without MetaMask so I was wondering if it is a good idea to run my own private node and to connect from the frontend like this: this.web3 = new Web3(new Web3.providers.HttpProvider('http://my-public-ip:8545')); Are there any security risks with this approach ? 回答1: I'm answering my own question because it seems that a lot of people are doinig the same mistake that I did and lose their ether ! I did

Testrpc error: 'no loggers could be found for logger 'jsonrpc.manager'

痞子三分冷 提交于 2019-12-12 01:56:56
问题 I'm trying to run truffle init and get the sample contract running. I run 'truffle init', 'truffle compile', & 'truffle migrate'. In a separate terminal window (same directory as the project), I run testrpc with no errors--I get the 10 hashes I'm supposed to get. So, In testrpc, this is the output when I run 'truffle migrate': Listening on localhost:8545 127.0.0.1 - - [2016-12-07 20:44:14] "POST / HTTP/1.1" 200 718 0.001816 No handlers could be found for logger "jsonrpc.manager". Could there