Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [golang]

Questions related to the Go programming language

0
votes
1answer
36 views

Reading genesis config on GoLang

In a custom fork of Ethereum my team is developing, we need to read a new config parameter from genesis block. At https://github.com/ethereum/go-ethereum/blob/master/cmd/evm/runner.go#L100 the code ...
0
votes
0answers
14 views

How to backup and restore txpool data?

I'm using Geth to create a PoA Clique based private blockchain. I'm currently facing this problem and I'm looking for ways to backup and restore txpool data. From the problematic node, this is my ...
3
votes
1answer
71 views

Calling contract method internally from geth code

On developing a custom geth fork there is the need to call a specific hardcoded smart contract when ETH transfer occur. This is not an Ethereum normal behaviour but a new feature we want to implement ...
1
vote
0answers
49 views

No contract code at give address

Its a bit of a long question... I am using Go to deploy a Smart Contract using the following code: client, err := ethclient.Dial("http://localhost:8545") if err != nil { errorhandler.HandleErr(...
0
votes
1answer
67 views

Genesis allocation and (address, balance) tuples

On go-ethereum souce code at core\genesis_alloc.go(19): ... package core // Constants containing the genesis allocation of built-in genesis blocks. // Their content is an RLP-encoded list of (...
0
votes
0answers
16 views

Handling EOF when subscribing to Event Logs

I'm trying to subscribe to events logs to handle Transfer(address,address,uint64) events. I've followed this example. https://github.com/miguelmota/ethereum-development-with-go-book/blob/master/en/...
0
votes
0answers
23 views

Private Ethereum network. How to create block with go-ethereum library?

The other day I decided to play around with Ethereum and write a simple program that will load the network with transactions as close as possible to the real environment. For these needs, I used my ...
1
vote
1answer
29 views

How to parse input data in transaction using go programming language?

I know there are some resolutions about parsing transaction input data, but they don't work with go. I wander if there is any way i can use with abi available. Specifically, When i receive a ...
1
vote
2answers
100 views

Given a RAW Transaction - how to get senders address

Is it possible to get the senders address using golang when all you have is the raw transaction string. I can decode it and get the nonce, hash, to etc as these are all exported functions from the ...
0
votes
1answer
36 views

Converting Log Topics to int64 correctly in Go

I currently use the code below to extract the ERC721 Token ID from Transfer Event Logs: txHash := newLog.TxHash.Hex() hexString := common.BytesToAddress(newLog.Topics[3].Bytes()).Hex() flowerNum, _ :=...
0
votes
1answer
21 views

How does one go about implementing the ContractTransactor interface from the bind package in go-ethereum?

Hey guys thanks in advance! Here is the interface provided by the go-ethereum library in the bin package. I need an example on how to implement this interface please :) // ContractTransactor ...
0
votes
0answers
69 views

Golang web3.eth.abi.encodeParameters equivalent

I need to encode some data in golang like using the web3.eth.abi.encodeParameters(paramsTypes[], params[]) I tried to use golang's ABI.Pack(functionName string, params) but it's not a good solution ...
0
votes
0answers
35 views

Can I use a WebSocket client for multiple abigen watchers?

I have question about abigen and websocket. My code is in Go. I'm sending a bunch of transactions using abigen and I'm using abigen to watch each of the transaction and do something when it's mined. ...
0
votes
0answers
41 views

Balance from ethereum accounts on geth disappears

I have geth private network with 3 accounts A, B and C. each account has 100, 200 and 300 ether balance I connected to this network from Metamask and Transferred the balance of 50 eth from account A ...
1
vote
2answers
275 views

GoEthereum getting public key from private key hex formatting

So I am trying to get public key in hex formatting. In some documentation I found the following will give public key from the private key, but it is not formatted correctly as I can see: publicKey := ...
2
votes
1answer
110 views

goethereum getting publicKeyBytes from given public key

Trying to follow this documentation on verifying a signature: https://goethereumbook.org/signature-verify/ Where I am a bit confused is this line: publicKeyBytes := crypto.FromECDSAPub(...
0
votes
1answer
35 views

Private ethereum network account related query

Please help with below queries: how to reset the paraphrase for an account on private ethereum network Is there a way to delete an account on private ethereum network How to enable the etherscan url ...
0
votes
0answers
26 views

Metamask to Private ethereum communication issue [duplicate]

When i connect to my private ethereum network using the 'Custom RPC' of the metamask, it is getting connected from the MetaMask. FYI, i am connecting from outside the network of my server, and all ...
1
vote
0answers
327 views

How to fix “unexpected directory layout” error when Installing go-ethereum?

All, I hope this question belongs here. I am following a Blockgeeks tutorial, trying to set up my environment for Ethereum blockchain development. I have basically gotten to the final step, ...
0
votes
1answer
39 views

How to use event log in solidity contract using go language

I have created ethereum smart contract using go language. Smart contract successfully deployed. I have a created many transactions on ethereum private network. But I confuse how to get event log.
0
votes
2answers
74 views

Golang Equivalent to list accounts on node - web3.eth.Accounts()

Does anyone know if its possible to get a list of the accounts on a node using golang, after Dialing to the node, basic PoC would be assuming the accounts are already unlocked via the CLI Basically ...
2
votes
1answer
116 views

How to convert string to type defined by an abi.Type for payload construction?

I am writing a CLI in Go that should faciliate users to be able to make contract function calls from it. This entails generating contract ABIs and providing input parameters to the function arguments ...
0
votes
1answer
207 views

How to correctly send RPC call using Golang to get smart-contract owner?

Update 12 November 2018 Someone shared a very close solution to what I was looking for here. Update 10 November 2018 Since I'm not able to achieve this using the approach in this question, I ...
0
votes
1answer
186 views

Golang binding - call contract method and get its return value or tuple?

Suppose i have contract like: pragma solidity ^0.4.11; contract MyToken { uint256 a; function SimpleGetter() returns(string) { return "something"; } function DoTheGreat(address _to) ...
0
votes
1answer
67 views

How do I check the Ethereum balance and unique transactions count of a Smart Contract over a period of time?

Basically I want to be able to track smart contracts balance and unique transactions over a period of time such as , last 24hours, last hour and so. What would be the best approach into doing this? ...
0
votes
2answers
35 views

Token transfer not dropped no event on MetaMask

I am using the following contract Fixed Contract Example And using this example to transfer token Transfer token example Everything goes fine, i see no error what so ever except MetaMask doesn't ...
0
votes
2answers
78 views

Golang - alloc large Wei amount to address

Im modifying the puppeth genesis wizard file for my own use case. I want to be able to assign a pre-set amount in Wei to a few chosen addresses.. Im having some trouble figuring out how to format the ...
1
vote
1answer
123 views

Golang How to slice Ethereum log events from smart contract to a more readable format

Im looking to use a channel to watch contract log events but the output returns a byte array like this the go code i am using looks like this package main import ( "...
2
votes
1answer
130 views

Invalid transaction signature on sending transaction

Hello guys I'm having a "Invalid transaction signature." error. Can't get pass this one. Am I missing something? client, err := ethclient.Dial("path/to/geth.ipc") if err != nil { return err } ks :...
2
votes
1answer
124 views

Cannot get transaction's field “From” using Golang

How I can get transaction's field "From"? client, err := ethclient.Dial("https://mainnet.infura.io") if err != nil { log.Fatal(err) } blockNumber := big.NewInt(5671744) block, err := client....
2
votes
1answer
293 views

ethereumjs-abi equivalent for Golang?

ethereumjs-abi is great for easily ABI encoding and decoding in javascript. Is there an equivalently simple package for Golang? Geth's accounts/abipackage does this, but there's a lot of setup and it'...
1
vote
1answer
77 views

It is possible to get bytecode from the evm in golang?

Imagine this scenario, I have a contract that has a function where I call with runtime.Call(). But this function returns an address of a newly created contract, but not the bytecode as runtime.Create ...
3
votes
0answers
62 views

Getting error message from require() using golang, and go-ethereum?

From everything I've been able to find, the only way you can get the error message from require() is by using remix which isn't practical for dealing with production issues. Therefore, I'm wondering ...
0
votes
1answer
308 views

go-ethereum event subscriptions doesn't work?

I'm new to go-ethereum and even Golang in general so my terminology might be wrong, I'm guessing event handling is also referred to as "subscription"? Anyways, my actual issue is that I want to test ...
0
votes
1answer
67 views

How to immediately close ethclient.Client RPC sockets so they don't linger in TIME_WAIT status on server?

My server is running out of available sockets while I am using goroutines (limited to 100 concurrently) because once a goroutine finishes the ethclient.Client socket stays open in TIME_WAIT status for ...
0
votes
2answers
39 views

Unable to retreive transaction balance before / after transfer

I am trying to wrap my head around the go ethereum library and sending transactions. The issue is that I want to be able to query the balance BEFORE the transaction and AFTER. The code below gives ...
1
vote
1answer
116 views

go-ethereum keccak256 multi value byte slice does not match solidity keccak256

I have a smart contract with the following function: function testHash( address _sender, uint8 _method, uint256 _number, uint256 _amount) public returns (bytes32) { ...
1
vote
2answers
1k views

Go Ethereum - get the enode before starting geth

I need to get the enode of my geth nodes before I start them up.. is there any way to do this via a command other than actually starting up the node ?
0
votes
0answers
174 views

Creating a new Consensus Algorithm based on Clique

Im working on refactoring clique consensus algorithm to use a smart contract. For my initial proof of concept I am using 2 files, each with 3 node addresses, I am using these files to populate the ...
0
votes
1answer
756 views

bower vs web3 vs nodejs vs golang apis

What benefits does the use of following bring to my Ethereum application if I wish to interact smart contracts for sending multiple transactions, upload files on blockchain, etc.? bower web3js ...
1
vote
2answers
251 views

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

How can we implement a new opcode in the Ethereum Virtual Machine. For eg : I want to implement an opcode logic such that the opcode number of this operation is 0x21. The EVM-implementation I am using ...
1
vote
1answer
471 views

From golang sha3 to solidity sha3

Trying to match "golang.org/x/crypto/sha3" lib with solidity sha3() is giving me a hard time. Its been discussed in here, but I somehow cant apply it in go. How do I handle a big.Int type s.t i get ...
1
vote
1answer
146 views

Adding JSON-RPC call in geth

I want to build a custom version of geth that provides a new JSON-RPC call to clients. It looks like there are two pieces to make that happen: (1) a Go implementation in internal/ethapi/api.go, and (...
1
vote
1answer
217 views

How to run local VM from golang?

I am going to run the virtual ethereum machine from the code, pass to it a compiled smart contract code. But I do not know how to do it. It's my code: package main import ( "context" "...
2
votes
1answer
774 views

How to send signed transaction to Ropsten through INFURA in Golang

I want to send and broadcast a signed transaction by sender to the Ropsten network through INFURA in Golang. I was able to send a signed transaction and recieved a response from INFURA as per below, ...
1
vote
1answer
171 views

How can I receive message by golang - whisper

In geth --shh --rpc console, for example I type f = shh.newMessageFilter({privateKeyId: id}, function(error, messages){console.log(JSON.stringify(messages))}) to receive a posted message by ...
2
votes
1answer
314 views

Using Golang how to get the number of transactions in a block

I cant seem to find any way to get the number or transactions within a block using the block number in golang.. anyone have any idea how to do this
0
votes
1answer
95 views

creating and array using type Big.Int and counting the sum of all integers inside it

Im communicating with a smart contract trying to get the balances from a list of addresses. I then want to get the sum of all balances but I am stuck on actually creating the array to store all the ...
2
votes
2answers
2k views

Convert byte Address to Hex

Using Geth I am reading from a smart contract and a list of addresses is retrieved when outputting to the terminal. These addresses are in byte array format: fmt.printLn("address", address) output = ...
2
votes
1answer
557 views

Developing native dapps with Go

so I was looking around for a decent up-to-date tutorial to start developing native dapps (C++ or GO doesn't really matter), but I can't seem to find a concise tutorial rather than this one. Can ...