Hot answers tagged

30 votes
Accepted

What is the merit of creating new smart contract languages like Solidity instead of using other languages?

Every programming language is designed for a particular operational environment and target tasks; and these constraints drive almost all design decisions on what features to support and which ones to ...
user avatar
14 votes
Accepted

LevelDB in Geth, key and values

Let's start with having a look at what we get in geth console for block number 40. Now let's consider a Go program. I Explained everything in code comments about how it is constructing keys and ...
user avatar
11 votes

why did it returned null after call miner.start()

Recently, there are so many people confused about miner.start(1) returning null, but it's actually not a problem, just a reasonable return value misunderstanding. If you aren't sure that your node is ...
user avatar
  • 2,121
10 votes

Go Ethereum - get the enode before starting geth

Using node hex in nodekey file under .ethereum/geth/nodekey and bootnode utility. Assuming you are using Linux. Check your nodekey hex : $ cat ~/.ethereum/geth/nodekey ...
user avatar
9 votes

How to decode input data with ABI using golang?

took me a bit of time to figure out that myAbi.Unpack(...) unpacks output of a method or event. In your case (and mine) we want to unpack the inputs. Here is a working code sample // example of ...
user avatar
  • 591
7 votes
Accepted

How to decode Log.Data in Go

go-ethereum abi package in Oct 2017 got the update to unpack event output. Initially it was only able to unpack method output. All functionality is delivered through the abi.ABI object. To use it you ...
user avatar
6 votes

why did it returned null after call miner.start()

try setting miner.setEtherbase(eth.coinbase) or step by step: start Mist browser (let the node synchronize completely) open console and type: geth attach miner.setEtherbase(eth.accounts[0]) miner....
user avatar
  • 194
6 votes

How to decode Log.Data in Go

Here's a full code example for anyone who's still confused (thanks to @Robert Zaremba's answer) package main import ( "context" "log" "math/big" "strings" "github.com/ethereum/...
user avatar
  • 4,715
6 votes

Unable to generate Go Ethereum Bindings using abigen

Make sure your gopath is correct export GOPATH=$HOME/go export PATH=$PATH:$GOPATH/bin Install abigen go get -u github.com/ethereum/go-ethereum cd $GOPATH/src/github.com/ethereum/go-ethereum/ make ...
user avatar
  • 4,715
6 votes
Accepted

How can we implement a new opcode in the Ethereum Virtual Machine.

I can only give you a general guide on how to do this: 1) Modify core/vm/instructions.go to add your instruction code, something like: func opAdd(pc *uint64, evm *EVM, contract *Contract, memory *...
user avatar
  • 3,406
5 votes

Ethereum HD Wallet implementation in Golang, is there any library in go?

You can use the package github.com/miguelmota/go-ethereum-hdwallet to implement an HD wallet (which implements the accounts.Wallet interface from go-ethereum). Here's a basic example to get started: ...
user avatar
  • 4,715
5 votes
Accepted

Convert byte Address to Hex

to convert from binary to hex, and back, use the package encoding/hex Hex ==> string: str := hex.EncodeToString(**your slice of bytes**) Hex <== string: b, err := hex.DecodeString(**your string*...
user avatar
  • 548
5 votes
Accepted

goethereum getting publicKeyBytes from given public key

You only need the public key in bytes format which means you don't need the private key at all and don't need the key in ecdsa type either. For example: publicKeyBytes, err := hex.DecodeString("...
user avatar
  • 4,715
4 votes

Is it possible to create a unique hash inside geth?

The answer to the question in the title is no, it is not possible to create a hash in Solidity that you are sure will be unique, at least given the possibility of block orphaning and reorgs. Users ...
user avatar
  • 16.3k
4 votes
Accepted

Dangling hash node ref: too many open files

Check Open File Descriptor Limits You may need to increase the Linux file limit to handle the number of connections your nodes are serving. Here are some articles on checking and setting the limits. ...
user avatar
4 votes
Accepted

Are there Ethereum API wrappers?

Not yet. We've just revamped the server side RPC internals in develop and are still ironing out some quirks. I can imagine we would soon-ish start working towards the directions of providing some Go ...
user avatar
4 votes

How to communicate with the JSON RPC server programmatically using Go?

You might take a look at a simplistic approach we took for etherapis: https://github.com/etherapis/etherapis/blob/master/etherapis/geth/api.go However there's an RPC client in the works that should ...
user avatar
4 votes
Accepted

How to validate an etherum address (go)?

From types.go: // IsHexAddress verifies whether a string can represent a valid hex-encoded // Ethereum address or not. func IsHexAddress(s string) bool { if hasHexPrefix(s) { s = s[2:] ...
user avatar
4 votes

Decode raw transaction

Using the official go-ethereum package: import ( "encoding/hex" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" &...
user avatar
  • 41
4 votes
Accepted

bower vs web3 vs nodejs vs golang apis

Bower: no one uses bower anymore as package manager for browser libraries. Use Yarn or NPM. Web3.js: the de-facto library for interacting with Ethereum in JavaScript and Node.js. It takes care of ...
user avatar
  • 4,715
4 votes

Go Ethereum - get the enode before starting geth

One of the binaries that can be generated by the go ethereum implementation is bootnode that can be used (as the name suggests) to create a bootnode, i.e. a node that is involved only in the p2p ...
user avatar
  • 1,734
3 votes

How generate number type uint256 in Go

One of the Golang gurus might want to comment further, but I don't think Go supports 256-bit integers natively. You could import Geth's number package, together with math/big, and use the relevant ...
user avatar
3 votes

why did it returned null after call miner.start()

The null is expected. If you are mining you will see lots of messages in your console like this: INFO [07-25|18:46:25] Successfully sealed new block number=72 hash=d0316e…36554e INFO [07-...
user avatar
3 votes
Accepted

Local caching database for fast retrieval

A two-part answer. "you need to loop": This just jumps out at me and deserves a comment. Smart Contracts don't give you indexed storage but this doesn't imply that a contract should loop over ...
user avatar
  • 51.4k
3 votes

How to communicate with the JSON RPC server programmatically using Go?

I don't have the solution for your code because I haven't looked into using the go-ethereum internals to do RPC calls but I've made a very small rpc client library you can find on my github that uses ...
user avatar
  • 2,331
3 votes
Accepted

ethereum-go how to get the latest block?

I made it work by adding a true parameter in err = client.Call(&lastBlock, "eth_getBlockByNumber", "latest", true) and changing *bit.Int to string Like this: package main import( "fmt" "...
user avatar
  • 66
3 votes
Accepted

Is it possible to include Go code in a Solidity contract?

First don't mix Go as the language used for building some Ethereum tools and base implementation and languages for writing smart contracts such as solidity that can be compiled into evm code. Today i'...
user avatar
3 votes

Raw transaction data in Go

The go-ethereum package provides a common.LeftPadBytes function for left padding values for solidity. You'd use this to pad to 32 bytes which is the word size the EVM uses. Here's a full example of ...
user avatar
  • 4,715
3 votes
Accepted

How to debug Geth's go code from within Intellij Webstorm?

First make sure you have the latest version, EAP 15, 173.2696.28, and you are using the latest version of Go, 1.9, as that's preferred for a better debugging experience due to the recent improvements ...
user avatar
  • 191

Only top scored, non community-wiki answers of a minimum length are eligible