Questions tagged [golang]
Questions related to the Go programming language
235 questions
0
votes
1
answer
34
views
How to encode transaction hash argument in go ethclient CallContext
I am trying to call debug_traceTransaction in go by doing:
cl, err := ethclient.Dial("http://localhost:8545")
if err != nil {
panic("Failed starting")
}
txnHash := common....
0
votes
0
answers
42
views
go -ethereum abi: cannot marshal in to go type: length insufficient 640 require 8225"
Im trying to decode a struct which basically is a tuple where i have this byte of data and passing the byte of data it will be able to be decoded into a struct in Go. My goal here is trying to create ...
1
vote
1
answer
279
views
How to do simulation of all/most pending transactions?
everybody. I have a task to search in mempool for transactions like "swap tokens for eth" or any other type where a wallet sells tokens and its transaction can affect token reserves. There ...
0
votes
0
answers
83
views
Abigen unable to generate go code for solidity enum type used inside a library used by other contracts
I am receiving the following error from abigen:
$ abigen --abi abi.json --pkg versioning --type Versioning --out versioning.go
Fatal: Failed to generate ABI binding: unsupported arg type: State
For ...
0
votes
1
answer
41
views
Call to view function, which returns a bytes value, got error: VM Exception while processing transaction: invalid opcode
I have this test smart contract
// SPDX-License-Identifier: SEE LICENSE IN LICENSE
pragma solidity 0.8.26;
contract TestSomething {
bytes state;
bytes32 state32;
constructor() {}
...
1
vote
1
answer
80
views
Abigen from flattened contract files
I have a file that is composed of 5 imports, too much code to drop here so I will illustrate my question with a very simplified example.
My Test.sol file:
// SPDX-License-Identifier: MIT
pragma ...
1
vote
0
answers
96
views
abi: attempting to unmarshal an empty string while arguments are expected
After updating go-etherum from github.com/ethereum/go-ethereum v1.10.22 to v1.13.15
My contracts started printing out error
abi: attempting to unmarshal an empty string while arguments are expected
...
1
vote
0
answers
73
views
Confusion regarding the technical implementation of PoS Consensus Mechanism in custom blockchain? Master Node?
I have been making my own custom blockchain just as a practice for the past few weeks.
The code is available here link to github repo
I have hitherto implemented the Execution Layer, so to speak. I ...
0
votes
0
answers
41
views
public key recovery failed intermittently with go-ethereum
I am trying to recover public key from signature and digest. below is my code. It's failing sometimes with error recovery failed
package main
import (
"crypto/ecdsa"
"crypto/...
3
votes
1
answer
84
views
for loop containing types.Sender sometimes does not leave and consumes 100% CPU
I have this simplified code here:
signer := types.LatestSignerForChainID(s.ethApiBackend.ChainConfig().ChainID)
log.Info("Before msg generation", "txsLen", len(txs))
msgs := make([]...
1
vote
1
answer
206
views
Using abigen with combined-json option generates nothing
I was trying to generate go binding using following commands:
abigen --combined-json UniswapV2PriceOracle.json --pkg abi --type UniswapV2 --out UniswapV2.go
It doesn't give any error, but the go file ...
2
votes
1
answer
132
views
How to correctly pack Log data in Go
Using go-ethereum, I want to convert a struct containing my log fields into a types.Log{} object containing the data bytes and topics. Essentially, I want to do the opposite of the Parse<EventName&...
2
votes
3
answers
475
views
How to implement the below solidity code in golang? especially the `abi.encode` function?
How to implement the below solidity code in golang? especially the abi.encode function?
abi.encode(
keccak256("delegate(address sender,string amount, string to)"),
sender,
amount,...
1
vote
0
answers
17
views
How does MetaMask confirm the trasaction? The workflow of metamask
I'm trying to make interaction between my customized chain and Metamask.
Network is added, and token sending is successful on chain side. But in MM, tx state is still pending. how can I fix that? What'...
0
votes
3
answers
559
views
Despite calculation I get contract creation code storage out of gas
My smart contract is deployed on https://sepolia.etherscan.io/tx/0x1b1742a3ff2ac160d5f245ab91828fcc56a803cb3826b6cbdb9f3cb2f293ba66
Once deployed I get contract creation code storage out of gas error
...
1
vote
1
answer
219
views
Why Golang was chosen to implement ethereum protocol?
I know there are many implementations of the Ethereum protocol, i.e. the first implementation in Python, or other implementations using C++, C#, and Java. As go-ethereum has gained lots of attention ...
0
votes
1
answer
35
views
How to implement solidity bitwise in Golang
Code in UniswapV3 Solidity contract
TickBitmap
uint256 mask = ~((1 << bitPos) - 1);
I had founded some example code in Golang:
a := new(big.Int).Exp(big.NewInt(2), big.NewInt(66), nil)
...
1
vote
0
answers
218
views
($10 ETH Bounty) Base Chain - My submitted transaction is always 2 blocks behind the current block
For some reason whenever I submit my transaction it is always included 2 or more blocks behind the current block. There's an address that always has their transaction included in the same block as the ...
1
vote
2
answers
148
views
How to analyze a tx data?
Given a transaction of type types.Transaction (golang go-ethereum), how can I analyze the data field and check if it has a swap or a sync event?
I know that ...
2
votes
1
answer
458
views
Generate r, s, v permit signature variables off chain using Golang
I'm trying to generate a signature in line with https://eips.ethereum.org/EIPS/eip-712
so that I can permit spending of tokens without having to call Approve() first.
this is my code so far:
func ...
0
votes
1
answer
91
views
Rate limiter not working
The following code has an expected duration of 1000ms.
package main
import (
"context"
"fmt"
"github.com/ethereum/go-ethereum/ethclient"
"golang.org/...
0
votes
1
answer
1k
views
Decoding tx data from view call in Golang
I have a view call in my Solidity code that looks like this:
function call1 (address[] calldata targets) external view returns(Return[] memory returnData)
And the struct from the array which is ...
0
votes
1
answer
263
views
How to create Solidity bytes[] input argument in Go for Ethereum contract call
I have a simple multicall contract in Solidity which has the following function:
function multiCall (address[] calldata targets,bytes[] calldata data) external view returns(Return[] memory returnData)
...
1
vote
1
answer
213
views
Compiling two smart contracts it the same folder cause duplicates
When I compile two contracts in the same folder I get duplicates. The following contracts, Store.sol
pragma solidity ^0.8.0;
contract Store {
event ItemSet(bytes32 key, bytes32 value);
...
2
votes
2
answers
1k
views
type *types.Transaction has no field or method AsMessage)
I am following
https://github.com/miguelmota/ethereum-development-with-go-book/tree/master/en/transaction-query
Complete code
package main
import (
"context"
"fmt"
&...
2
votes
1
answer
125
views
Why is the same set of bytes encoded base58 differently?
I want to generate a bip32 private root key based on bip39 seed. I found an article with python code, copied it to myself and executed it, getting a valid private root key (checked here). Then I wrote ...
0
votes
1
answer
282
views
How to properly handler error from contract call with go etheruem
I am writing an application with https://github.com/ethereum/go-ethereum
Basically I am trying to check a given smart contract address is erc20 or not. I am calling getBalance, getSymbol... methods. ...
0
votes
1
answer
1k
views
go ethereum bigint and unit256
Golang can only handles up to 64 int however ethereum contract call can return uint256 for example https://eips.ethereum.org/EIPS/eip-20 balanceOf method.
Does https://github.com/ethereum/go-ethereum ...
0
votes
1
answer
106
views
SSZ serialization in Ethereum
I am looking at the SSZ serialization for Ethereum and am unable to understand how the "index" alone can be used for encoding/decoding variable length fields. The following is quoted from ...
1
vote
1
answer
65
views
how many transactions we can go in a personal blockchain made with geth ( go-ethereum ) per second or per block?
If I made a personal blockchain using https://geth.ethereum.org/, how many transactions can one block handle?
0
votes
1
answer
353
views
what consensus client is used while making personal blockchain with geth ( go-ethereum)?
Modular EVM based blockchain have multiple layers. mainly consensus layer and execution layer.
Execution layer options:
Besu
Erigon
Go Ethereum
Nethermind
consensus clients options:
Lighthouse
...
2
votes
0
answers
486
views
Simulate transaction replacement on go-ethereum SimulatedBackend
i'm writing in go-lang and using go-ethereum package to interact with nodes. For testing purposes go-ethereum provides blockhchain simulation via SimulatedBackend (https://github.com/ethereum/go-...
2
votes
0
answers
1k
views
Getting ALL pending tx from txPool
I'm working on top of geth in golang. My first goal would be to stream all pending transactions from the txPool.
The problem is that when I run my script, I can't manage to catch 100% of pending ...
0
votes
1
answer
15
views
identify past malicious transitions on blockchain?
Do you know any way to identify past malicious transitions on blockchain?
Like if you see a large number of transactions going to a single address, or if you see transactions that seem to be moving ...
0
votes
1
answer
56
views
Trying to find difference between ERC20 and ERC721, any help please?
Getting this error when I try to run the following code which is supposed to check kthe receipt topics and if they are 4 then it should be ERC721 contract creation transaction and if 3 than it is ...
1
vote
0
answers
447
views
Flashbots - Bundle simulation always reverts
I have a series of transactions I'm trying to bundle in golang.
several of the transactions are signed transactions from a range of different wallets that are not yet submitted to the mempool.
When I ...
4
votes
1
answer
965
views
Convert pem public key into ethereum address by Go
I have ECC_SECG_P256K1 Public key PEM File generated by AWS KMS.
I want to convert pem public key into ethereum address by Go.
How can I get it?
Sample Pem Data
-----BEGIN PUBLIC KEY-----
...
0
votes
1
answer
104
views
how connect in rpc file go ethereum
i try much more time to connect rpc my geth, i got it cant run ,,syncmode light,, okay but can i used --syncmode fast? or how i connect in my rpc file , to be read from the geth side, also see the ...
1
vote
2
answers
528
views
How to represent uint256 in EVM using Golang?
I am asked to build a small EVM with few instructions using Golang. What I am confused about is how to represent the uint256 data type? Because Golang supports at most uint64 for integer type. What I ...
2
votes
1
answer
724
views
How to use contractAbi.Unpack to parse raw log data into a log type struct
I am following the guide here but I am not able to replicate what is being done in the guide.
var transferEvent LogTransfer
err := contractAbi.Unpack(&transferEvent, "Transfer", vLog....
0
votes
1
answer
98
views
Decode Ethereum Gas Price Golang
I needed to get gas data from a transaction, I did it with the code below. The received data has been converted to a string. Now I need to decode the received value. How can I do this?
import (
&...
0
votes
2
answers
135
views
Is deploying that expensive?
I'm trying to deploy a smart contract and get this error each time
Warning! Error encountered during contract execution [contract creation code storage out of gas]
pragma solidity ^0.8.4;
// it has ...
0
votes
3
answers
666
views
How can I query the onchain data on the ethereum blockchain without using any APIs?
I want to get all the onchain data available on the Ethereum blockchain about an NFT from its contract address and tokenID. Like its metadata, the current owners, its last price, etc.
How can I do ...
0
votes
1
answer
292
views
Rust vs Golang, overall for smart contract development
Assuming I do not know anything about these two languages (rust & go), I know rust is being used to write contracts for solana and I do not have much idea of golang, I am thinking of learning one ...
1
vote
0
answers
104
views
Why is the TransactionByHash function in the go-ethereum client unable to return the sender?
I learned how to get the sender's address from this question. JSON-RPC returns a result with a from field, which we can unmarshal in our struct.
But I'm curious why go-ethereum didn't return ...
0
votes
1
answer
273
views
How to read ERC1155's SafeTransferFrom() transactions in golang?
Trying to read ERC1155 SafeTransferFrom events, in golang.
Here is what I tried:
var (
// erc 1155
logSafeTransferFromSig = []byte("SafeTransferFrom(address,address,uint256,uint256,...
1
vote
0
answers
78
views
Point a Go-Ethereum contract instance at a different address
I am running a golang backend that will interact with tens of thousands of deployed contracts that are all the same, just with different addresses (uniswap pools). I am thinking that it would be more ...
2
votes
1
answer
2k
views
Transaction Effective Gas Price
I am developing in Go and I have a question that I have been looking for the solution for a long time and I am not able to find it.
How can I find the effective gas price used in the transaction? Not ...
2
votes
0
answers
215
views
Subscribe to smart contract using go-ethereum
I am trying to subscribe to certain smart contract using go-ethereum.
Here is the example of my function
client, err := ethclient.Dial(config.AppConfig.SmartcontractHost)
if err != nil {
log.Fatal(...
1
vote
1
answer
115
views
How to filter return value from go-ethereum evm runtime.call
I am writing simple solidity code that's will be running inside evm using golang (go-ethereum). I have successfully run the code, but I can't find the right return value of the function.
Test.sol
// ...