ethereum

How is the source code protected from being tampered with in a blockchain?

懵懂的女人 提交于 2019-12-08 05:16:01
问题 class Block{ constructor(timestamp, transactions, previousHash = ''){ this.timestamp = timestamp; this.transactions = transactions; this.previousHash = previousHash; this.hash = this.calculateHash(); this.nonce = 0; } calculateHash(){ return SHA256(this.previousHash + JSON.stringify(this.transactions) + this.timestamp + this.nonce).toString(); } mineBlock(difficulty){ while(this.hash.substring(0, difficulty) !== Array(difficulty + 1).join("0")){ this.nonce++; this.hash = this.calculateHash();

How to debug geth with goland?

随声附和 提交于 2019-12-08 05:13:55
问题 I would like to be able to debug through Geth's Go code - using Goland. It looks to me as if the entry point for Geth is main.go, however, when I try to run this I get the following errors: GOROOT=/usr/local/Cellar/go/1.11/libexec #gosetup GOPATH=/Users/codet/go #gosetup /usr/local/Cellar/go/1.11/libexec/bin/go build -o /private/var/folders/6t/tdn_s_2x2rx1scn774cwvlph0000gn/T/___geth_go -gcflags "all=-N -l" /Users/codet/go/src/github.com/ethereum/go-ethereum/cmd/geth/main.go #gosetup #

Repeating transactions hangs - web3js, local geth

為{幸葍}努か 提交于 2019-12-07 08:25:44
问题 I have an issue with transactions on my local ethereum network - at some point, transaction hangs & spends a lot of ETH from my account. Here's a sample code: async function send(toAccount, weiVal) { let account = await w3.getDefAccount(); for (let i = 0; i < 100; i++) { let res = await web3.eth.sendTransaction({ from: account, to: toAccount, value: weiVal }); await helper.timeout(2000); } } send('0x5648...', 100000000000000); It hangs at sendTransaction call (promise is never resolved) on

How do I connect to a private network from ethereum wallet?

狂风中的少年 提交于 2019-12-07 02:28:59
问题 How do I connect to a private network from ethereum wallet? I was able to create a private network from geth command line using custom genesis file but now wanted my ethereum wallet to point to custom genesis file of the private network.Currently I am able to point my etherem wallet to either the mainnet or testnet but not private network. I did find the following instructions on github mist browser Readme file but haven't been able to make much progress To run a privatenet you need to have

How to debug geth with goland?

家住魔仙堡 提交于 2019-12-06 19:35:25
I would like to be able to debug through Geth's Go code - using Goland. It looks to me as if the entry point for Geth is main.go, however, when I try to run this I get the following errors: GOROOT=/usr/local/Cellar/go/1.11/libexec #gosetup GOPATH=/Users/codet/go #gosetup /usr/local/Cellar/go/1.11/libexec/bin/go build -o /private/var/folders/6t/tdn_s_2x2rx1scn774cwvlph0000gn/T/___geth_go -gcflags "all=-N -l" /Users/codet/go/src/github.com/ethereum/go-ethereum/cmd/geth/main.go #gosetup # command-line-arguments cmd/geth/main.go:136:3: undefined: configFileFlag cmd/geth/main.go:177:3: undefined:

How is the source code protected from being tampered with in a blockchain?

白昼怎懂夜的黑 提交于 2019-12-06 17:25:52
class Block{ constructor(timestamp, transactions, previousHash = ''){ this.timestamp = timestamp; this.transactions = transactions; this.previousHash = previousHash; this.hash = this.calculateHash(); this.nonce = 0; } calculateHash(){ return SHA256(this.previousHash + JSON.stringify(this.transactions) + this.timestamp + this.nonce).toString(); } mineBlock(difficulty){ while(this.hash.substring(0, difficulty) !== Array(difficulty + 1).join("0")){ this.nonce++; this.hash = this.calculateHash(); } console.log("Block mined: " + this.hash); } } In the above code, how is it promised that the

How to return mapping list in Solidity? (Ethereum contract)

余生长醉 提交于 2019-12-06 17:18:02
问题 I want to make simple smart contract that has a list, can set item, and can get the list. Code in solidity: contract lister { mapping(int => string) list; int id = 0; function getList() returns ( /*HERE*/ ) { return list; } function setItemToList(string str) { list[id] = str; id++; } } I want to make getList() return the list, but return type is not compatible. How can I do that? 回答1: Bulk access to lists/arrays/etc is painful in Solidity. You rarely see it in contracts. In your case, a

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

放肆的年华 提交于 2019-12-06 15:21:05
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 your migration will hang. Starting migrations... ====================== > Network name: 'development' >

Blog1 安装geth和Ethereum wallet

蓝咒 提交于 2019-12-06 13:12:22
Blog1 安装geth和Ethereum wallet并且接入公共测试网络Rinkeby实现转账等功能 写在前面的话: 本文测试的为Rinkeby公共网,在安装好Ethereum wallet(下面简称wallet)和geth之后请先测试Rinkeby测试网,不要先自己搭建私有链(当然也可以尝试,但是因为区块链去中心化的特点,更多的节点运行才能达到理想效果;公链的话同步区块太久,成本太大,对于初学者来说测试链更加友好)。如果已经尝试先搭建过私有链,请看这篇文章: 附:当尝试各种方法都无法接入Rinkeby的时候,可以尝试以下方法 关于以太坊公开的4个测试网络的区别以及geth、Ethereum wallet和mist的区别,请看这篇文章: 关于以太坊公开的4个测试网络的区别以及geth、Ethereum wallet和mist的区别 注: 在最新版本的wallet中,测试网络只有Rinkeby和Ropsten; 目前开发人员最常用的测试网络是Rinkeby,我们将尝试连接Rinkeby 环境:Windows、VPN 步骤: 在电脑D盘下新建文件夹Eth 下载最新版本的Ethereum wallet,进入github进行对应下载:https://github.com/ethereum/mist/releases,将下载好的压缩包放入文件夹Eth。 进入https://geth

4种测试网络以及geth、Ethereum wallet和mist的区别

雨燕双飞 提交于 2019-12-06 13:02:08
关于以太坊公开的4个测试网络的区别: A. Morden(已退役) Morden是以太坊官方提供的测试网络,自2015年7月开始运行。到2016年11月时,由于难度炸弹已经严重影响出块速度,不得不退役,重新开启一条新的区块链。Morden的共识机制为PoW。 B. Ropsten(区块链浏览器) Ropsten也是以太坊官方提供的测试网络,是为了解决Morden难度炸弹问题而重新启动的一条区块链,目前仍在运行,共识机制为PoW。测试网络上的以太币并无实际价值,因此Ropsten的挖矿难度很低,目前在755M左右,仅仅只有主网络的0.07%。这样低的难度一方面使一台普通笔记本电脑的CPU也可以挖出区块,获得测试网络上的以太币,方便开发人员测试软件,但是却不能阻止攻击。 PoW共识机制要求有足够强大的算力保证没有人可以随意生成区块,这种共识机制只有在具有实际价值的主网络中才会有效。测试网络上的以太币没有价值,也就不会有强大的算力投入来维护测试网络的安全,这就导致了测试网络的挖矿难度很低,即使几块普通的显卡,也足以进行一次51%攻击,或者用垃圾交易阻塞区块链,攻击的成本及其低廉。 2017年2月,Ropsten便遭到了一次利用测试网络的低难度进行的攻击,攻击者发送了千万级的垃圾交易,并逐渐把区块Gas上限从正常的4,700,000提高到了90,000,000,000,在一段时间内