umbracle / ethgo Goto Github PK
View Code? Open in Web Editor NEWEthereum Golang API
Home Page: https://www.ethgoproject.io
License: Mozilla Public License 2.0
Ethereum Golang API
Home Page: https://www.ethgoproject.io
License: Mozilla Public License 2.0
I am running into an issue when creating a transaction from a web3 contract. While reading through the docs, I noticed that you could create a transaction through the Txn() method on a contract. When doing this, I receive a panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xc1ee58]
error.
Here is my code that produces the error.
client, err := jsonrpc.NewClient(URL)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
//create a web3 contract
//initialize the contract abi
abi, err := abi.NewABI(abiString)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
//initialize the contract instance
contractAddress := web3.HexToAddress(contractAddressHex)
contractInstance := contract.NewContract(contractAddress, abi, client)
//create a transaction to call the approve function on the contract address
// Solidity function: approve(address spender, uint256 amount) external returns (bool);
transaction := contractInstance.Txn("approve", spenderWalletAddress, 99999999999999999)
When the program creates the transaction, it panics and throws the error mentioned above. Do you know if there is a way to fix this?
First of all, great work!
I have the following payload:
{"data":"0x095ea7b30000000000000000000000001111111254fb6c44bac0bed2854e76f90643097dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","gasPrice":"15000000000","to":"0x55d398326f99059ff775485246999027b3197955","value":"0"}
I want to convert this to a web3.CallMsg
and send it to web3.Eth().EstimatedGas(msg)
but I don't know how. This is what I came up with so far:
type ParsedMsg struct {
From string `json:"from"`
To string `json:"to"`
Data string `json:"data"`
GasPrice decimal.Decimal `json:"gasPrice"`
Value decimal.Decimal `json:"value"`
}
t := ParsedMsg{}
raw := `{"data":"0x095ea7b30000000000000000000000001111111254fb6c44bac0bed2854e76f90643097dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","gasPrice":"15000000000","to":"0x55d398326f99059ff775485246999027b3197955","value":"0"}`
if err = json.Unmarshal([]byte(raw), &t); err != nil {
return Order{}, fmt.Errorf("1inch decode trans err %s", err)
}
to := web3.HexToAddress(t.To)
trans := web3.CallMsg{
From: web3.HexToAddress(WalletAddress), // my wallet here
To: &to,
Data: []byte(t.Data),
GasPrice: t.GasPrice.BigInt().Uint64(),
Value: t.Value.BigInt(),
}
gas, err := ex.RPCClient.Eth().EstimateGas(&trans)
if err != nil {
fmt.Errorf("err getting gas %s", err)
}
This returns the error {"code":-32000,"message":"execution reverted"}
I'm pretty sure the problem is how I'm converting the data in bytes here []byte(t.Data)
. Any tips on how to do this?
Add support to read/write to JSON wallet described here https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition#alterations-from-version-2
go get github.com/ethereum/go-ethereum
run go mod tidy
,get this error
github.com/ethereum/go-ethereum/crypto imports
github.com/btcsuite/btcd/btcec/v2/ecdsa tested by
github.com/btcsuite/btcd/btcec/v2/ecdsa.test imports
github.com/btcsuite/btcd/chaincfg/chainhash: ambiguous import: found package github.com/btcsuite/btcd/chaincfg/chainhash in multiple modules:
github.com/btcsuite/btcd v0.21.0-beta (/Users/crx/go/pkg/mod/github.com/btcsuite/[email protected]/chaincfg/chainhash)
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0 (/Users/crx/go/pkg/mod/github.com/btcsuite/btcd/chaincfg/[email protected])
When I try to pull this address, this warehouse is deleted.
At the moment I can't see any method of passing in Basic Auth for bare metal nodes. At Blockdaemon some of our nodes require authentication to be used which requires tokens to be passed in as headers on HTTP requests. I've written a really basic method to amend it and retain all the original functionality of the jsonrpc.Client type. Where the headers are passed down and ignored where possible. I'm happy to share this code if required or if you have your own implementation/pattern you'd like to use I'm happy to collaborate on it?
Below are the key changes to these methods/structs.
func NewClient(addr string) (*Client, error) {
NewClientWithHeaders(addr, nil)
}
func NewClientWithHeaders(addr string, headers map[string]string) (*Client, error)
func newHTTP(addr string, headers map[string]string) *HTTP {
return &HTTP{
addr: addr,
client: &fasthttp.Client{},
headers: headers,
}
}
I am getting an error: panic: runtime error: slice bounds out of range [:32] with capacity 0
github.com/umbracle/go-web3/abi.decode(0xc000543950, 0x4868ad8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc0002a3a50, ...)
/.../github.com/umbracle/go-web3/abi/decode.go:47 +0x839
in some cases when triggering smart contracts return unexpected results.
I think that this can be fixed in this file: abi/decode.go
This part:
if t.isVariableInput() {
length, err = readLength(input)
if err != nil {
return nil, nil, err
}
} else {
data = input[:32]
}
can be replaced with
if t.isVariableInput() {
length, err = readLength(input)
if err != nil {
return nil, nil, err
}
} else {
if len(input) < 32 {
return map[string]interface {}{}, nil, err
}
data = input[:32]
}
Hello,
First I want to say thank you for this library that is helping us a lot by using the Encode
function. We were very surprised that this functionality was not available in go-ethereum and relieved that this package existed.
What we noticed using this package are 2 things that can be improved:
Sending float64 as number
When passing arguments in JSON, the numbers are typed as float64
. So if you are passing an interface{}
that comes from JSON. The package will fail because float64
is not accepted. This would be trivial to fix in the package (if you expect int, int8, etc, uint, uint8...
and receive float64
, just cast it into the correct type)
Sending addresses as strings
When passing addresses in JSON, they are strings prefixed with "0x". The package does not work if it expects an address and receives a string. This would be trivial to fix in the package (if you expect address
and receive string, just try to cast it into Address
)
I can do a quick PR for these fixes
package main
import (
"fmt"
"github.com/umbracle/go-web3/jsonrpc"
"github.com/umbracle/go-web3/wallet"
)
func main() {
client, err := jsonrpc.NewClient("https://eth-rinkeby.alchemyapi.io/v2/oYHKrgZwrX8PV76knF7hVPekQ8b5mCFd")
if err != nil {
panic(err)
}
number, err := client.Eth().BlockNumber()
if err != nil {
panic(err)
}
fmt.Println(number)
key, _ := wallet.GenerateKey()
fmt.Println(key.Address())
}
I got error:
../../../../../go/pkg/mod/github.com/umbracle/[email protected]/wallet/wallet_hd.go:26:17: key.Child undefined (type *hdkeychain.ExtendedKey has no field or method Child)
Close this if you feel like it, but I think a lot of people would benefit from seeing how a basic contract deployment would work to a connected web3 provider. Reading through the library it is hard to understand how to deploy a contract from json abi ([{"payable": true,"stateMutability": "payable","type": "fallback"}])and bytecode, being able to do so would be hugely helpful to people like me hoping to use something like Yul or Fe. Would appreciate generating abi atleast, as I am unable to call the deploy contract method without it.
Hi,
I used the example at https://github.com/umbracle/go-web3/blob/master/e2e/transaction_test.go and was successfully create a pending transaction: https://etherscan.io/tx/0x05d1ee5cef180e2b1c1313a9e310c2021c1beb9cc33b90d0c54b03b63653205a
However, it seems that the transaction has type 0, which is a legacy type, and end up being pending forever. Is there away to explicitly set the type of transaction to 0x2
, which is EIP-1155
, or am I missing some details somewhere?
The regex that checks a valid signature does not handle cases where a function does not have a return value.
function approve(address to, uint256 tokenId)
error: no matches found
var funcRegexp = regexp.MustCompile("(.*)\\((.*)\\)(.*) returns \\((.*)\\)")
func parseMethodSignature(name string) (string, *Type, *Type, error) {
name = strings.TrimPrefix(name, "function ")
matches := funcRegexp.FindAllStringSubmatch(name, -1)
if len(matches) == 0 {
return "", nil, nil, fmt.Errorf("no matches found")
}
// ...
}
curl -H "Content-Type: application/json" -d '{"id": 1, "method": "eth_getTransactionByHash", "params": ["0xd94650def68f99443c3557cb0c9e602de8dd54b8c3b1df6a115c2e4c75b78e03"]}' localhost:58545
{"jsonrpc":"2.0","id":1,"result":{"blockHash":"0xd5b8cb3d127f2c4657bb258deeb7bfe941f139ab0444ab151eea5f166e920734","blockNumber":"0xd380ac","from":"0xd33937c55fe4d030b4e2c55d2c0be0c6072285ca","gas":"0x493e0","gasPrice":"0x2540be400","maxFeePerGas":"0x2540be400","maxPriorityFeePerGas":"0x2540be400","hash":"0xd94650def68f99443c3557cb0c9e602de8dd54b8c3b1df6a115c2e4c75b78e03","input":"0x38ed17390000000000000000000000000000000000000000000000008256c4aa3376c0480000000000000000000000000000000000000000000000000017b235177be89c00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000d33937c55fe4d030b4e2c55d2c0be0c6072285ca000000000000000000000000000000000000000000000000000000006241c8820000000000000000000000000000000000000000000000000000000000000002000000000000000000000000a71edc38d189767582c38a3145b5873052c3e47a00000000000000000000000003dfd917677de9321249da24d47950964fd3034c","nonce":"0x145","to":"0xed7d5f38c79115ca12fe6c0041abb22f0a06c300","transactionIndex":"0x1d","value":"0x0","type":"0x2","accessList":[],"chainId":"0x80","v":"0x0","r":"0xbf77da9ad8bd08a9cd696189cb4d17ccc632529d0d4967eaa90f6c76c1884199","s":"0x2d6bac30aff7842d324b965d6ae7c6a62142c433acdfa64ef574bc2b168fa688"}}
strHash := "0xd94650def68f99443c3557cb0c9e602de8dd54b8c3b1df6a115c2e4c75b78e03"
txHash := ethgo.HexToHash(strHash)
tx,err1 := Client.Eth().GetTransactionByHash(txHash)
Logging.Infof("hash:%s %+v",strHash, tx)
hash:0xd94650def68f99443c3557cb0c9e602de8dd54b8c3b1df6a115c2e4c75b78e03 &{Type:2 Hash:0xd94650def68f99443c3557cb0c9e602de8dd54b8c3b1df6a115c2e4c75b78e03 From:0xd33937c55fe4d030B4E2c55D2c0be0C6072285CA To:0xED7d5F38C79115ca12fe6C0041abb22F0A06C300 Input:[56 237 23 57 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 130 86 196 170 51 118 192 72 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 23 178 53 23 123 232 156 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 160 0 0 0 0 0 0 0 0 0 0 0 0 211 57 55 197 95 228 208 48 180 226 197 93 44 11 224 198 7 34 133 202 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 98 65 200 130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 167 30 220 56 209 137 118 117 130 195 138 49 69 181 135 48 82 195 228 122 0 0 0 0 0 0 0 0 0 0 0 0 3 223 217 23 103 125 233 50 18 73 218 36 212 121 80 150 79 211 3 76] GasPrice:10000000000 Gas:0 Value:+0 Nonce:325 V:[0] R:[191 119 218 154 216 189 8 169 205 105 97 137 203 77 23 204 198 50 82 157 13 73 103 234 169 15 108 118 193 136 65 153] S:[45 107 172 48 175 247 132 45 50 75 150 93 106 231 198 166 33 66 196 51 172 223 166 78 245 116 188 43 22 143 166 136] BlockHash:0x0000000000000000000000000000000000000000000000000000000000000000 BlockNumber:0 TxnIndex:0 ChainID:+128 AccessList:[] MaxPriorityFeePerGas:+10000000000 MaxFeePerGas:+10000000000}
contract example is error
Method signature
issueByPartition(bytes32,address,uint256,bytes)
method := web3ABI.GetMethodBySignature("issueByPartition(bytes32,address,uint256,bytes)")
args = [
"0x697373756564000000000000636c617373610000000000000000000000000000",
"0x4D61778D0b517A79Fa9482003a1E44C24e15Ab1f",
"0x21e19e0c9bab2400000",
"0x5fa921675accc24059691b13865835eed09bf23ce61d0e89b1d4e690116942000000000000000000000000000000000000000000000000000000000061fd657ca6cce2e20c4f5aa1c36951da5f524e7c6ffc6d59ccd4be26fd2e030b53e05c9e2756396bceabe6b5c32c9c72e65a095f9b4d67a10278b1d9972bbc1432f95a9d00"
]
txData, err := method.Encode(args)
Actual result
It panics, see logs below
Expected result
It should encode argument correctly
Logs
api_1 | 2022/02/04 16:42:20 http: panic serving 172.24.0.1:58708: reflect: call of reflect.Value.Bytes on string Value
api_1 | goroutine 268704 [running]:
api_1 | net/http.(*conn).serve.func1(0xc0061f6000)
api_1 | /usr/local/go/src/net/http/server.go:1804 +0x153
api_1 | panic(0x2d62ea0, 0xc005b11bd8)
api_1 | /usr/local/go/src/runtime/panic.go:971 +0x499
api_1 | reflect.flag.mustBe(...)
api_1 | /usr/local/go/src/reflect/value.go:221
api_1 | reflect.Value.Bytes(0x2c592e0, 0xc00557dcd0, 0x98, 0x4e38b7, 0x2d349c0, 0x0)
api_1 | /usr/local/go/src/reflect/value.go:289 +0xfc
api_1 | github.com/umbracle/go-web3/abi.encodeFixedBytes(0x2c592e0, 0xc00557dcd0, 0x98, 0x2c592e0, 0xc00557dcd0, 0x98, 0x4087, 0x7e00)
api_1 | /go/pkg/mod/github.com/umbracle/[email protected]/abi/encode.go:175 +0x55
api_1 | github.com/umbracle/go-web3/abi.encode(0x2d349c0, 0xc005ac45c0, 0x194, 0xc005f6f180, 0x2d349c0, 0xc005ac45c0, 0x194, 0xc00597a1b0, 0x7fb7c01e3e5b)
api_1 | /go/pkg/mod/github.com/umbracle/[email protected]/abi/encode.go:50 +0x389
api_1 | github.com/umbracle/go-web3/abi.encodeTuple(0x2beaee0, 0xc005b11bc0, 0x97, 0xc0060cd310, 0xc00597a240, 0x16, 0xa, 0x2b68640, 0xc000b23c08)
api_1 | /go/pkg/mod/github.com/umbracle/[email protected]/abi/encode.go:149 +0x2fe
api_1 | github.com/umbracle/go-web3/abi.encode(0x2beaee0, 0xc005b11bc0, 0x97, 0xc0060cd310, 0xc003ec0c68, 0x412d1b, 0xc005b11bc0, 0x18, 0x18)
api_1 | /go/pkg/mod/github.com/umbracle/[email protected]/abi/encode.go:32 +0x405
api_1 | github.com/umbracle/go-web3/abi.Encode(0x2beaee0, 0xc005b11bc0, 0xc0060cd310, 0x18, 0xc005b11bc0, 0x37a0301, 0xc000100400, 0x0)
api_1 | /go/pkg/mod/github.com/umbracle/[email protected]/abi/encode.go:19 +0xb1
api_1 | github.com/umbracle/go-web3/abi.(*Method).Encode(0xc005bc1b30, 0x2beaee0, 0xc005b11bc0, 0xc005b11bc0, 0xc0008b1230, 0xc004a58780, 0x6, 0xc0065c0900)
api_1 | /go/pkg/mod/github.com/umbracle/[email protected]/abi/abi.go:189 +0x50
api_1 | github.com/consensys/orchestrate/services/api/business/use-cases/transactions.(*sendContractTxUseCase).Execute(0xc000aeeae0, 0x3803c80, 0xc005abfa40, 0xc000c09b60, 0xc000c09b00, 0x0, 0x312a4c0, 0x30)
api_1 | /app/services/api/business/use-cases/transactions/send_contract_tx.go:65 +0x606
Other
Version github.com/umbracle/go-web3 v0.0.0-20220112152710-157826f66053
The PostgreSQL tracker store uses docker to run postgres instances with the dockertest library. However, the setup does not work on CircleCI.
the following curl requests are not returned consistently from nodes
block 1067050
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionReceipt","params":["0xcbb8db2cec3fa38e2ff221462708252bbbe32abb57e5a43f402155880d2883e0"],"id":1}'
block 15627984
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionReceipt","params":["0xdd002538bd3165c8aed8a7435f965420bca4406951e490190f4271302a4c5254"],"id":1}'
the error produced is field 'status' not found
which is true, it is not found in the response for the older transaction
Currently, to encode a tuple you have to use an array. Make it flexible so that the user can use either a map or a struct.
This is a tracking issue to manage any problems during the renaming of the library from go-web3
to ethgo
.
Initially, the name go-web3 was meant to be a reference to web3.js, one of the official javascript libraries for Ethereum. However, as time passed, the name web3 has become a generic name on the industry for many blockchain related applications. This might be confusing for developers since this library is only meant to be used for Ethereum compatible blockchains.
In that regard, I think the new name makes a much more clear statement of what the library does.
The current testutil
does not premine any accounts at genesis and uses the dev
unlocked accounts to send transactions and fund other accounts with the eth_sendTransaction
endpoint. There are two main reasons to move away from this workflow:
eth_sendTransaction
endpoint will be available (i.e. neither Erigon nor Polygon-Edge includes it).The work would require to use a custom genesis file to setup the premined accounts and use it instead of the bultin genesis file for dev.
Hello,
Could it be possible to get the web3 encodeFunctionCall
?
=> https://web3js.readthedocs.io/en/v1.5.2/web3-eth-abi.html#encodefunctioncall
I tried to make something but I did not completely get how to format dynamic types.
It would be very helpful if you can provide an out-of-the-box function that does this.
https://etherscan.io/address/0x93a796b1e846567fe3577af7b7bb89f71680173a#code try using the ABI from here with UnmarshalJSON();
in the decoder the type with name "error" isn't accounted for and throws an error.
`for _, field := range fields {
switch field.Type {
case "constructor":
if a.Constructor != nil {
return fmt.Errorf("multiple constructor declaration")
}
a.Constructor = &Method{
Inputs: field.Inputs.Type(),
}
case "function", "":
c := field.Constant
if field.StateMutability == "view" || field.StateMutability == "pure" {
c = true
}
a.Methods[field.Name] = &Method{
Name: field.Name,
Const: c,
Inputs: field.Inputs.Type(),
Outputs: field.Outputs.Type(),
}
case "event":
a.Events[field.Name] = &Event{
Name: field.Name,
Anonymous: field.Anonymous,
Inputs: field.Inputs.Type(),
}
case "fallback":
case "receive":
// do nothing
default:
return fmt.Errorf("unknown field type '%s'", field.Type)
}
}`
Current behavior
Passing a method signature such with complex usage of tuples such as multipleTransfer((address,(uint256,address)[]))
(which is equal to multipleTransfer(tuple(address,tuple(uint256,address)[]))
fails
Expected behavior
Using NewMethod(multipleTransfer("(address,(uint256,address)[])"))
should succeed in parsing the method signature into a valid Method with the correct inputs as tuple.
To support real-time service, we may need to support event subscriptions. Now the tool use eth_getLogs to track the incoming events, which may not be an efficient solution in some ways.
Wondering how to define basic tx data on contract calls.
At the moment can only send the function params but failing due to low nonce (obvious)
Mac m1 macos 12.4
Docker Desktop 4.10.1
When run abi/encoding_test.go/TestEncoding(t *testing.T)
function
The testsuit/server.go
NewTestServer()
created a geth client, but port 8545 can't be reached.
func (t *TestServer) HTTPAddr() string {
return fmt.Sprintf("http://%s:8545", t.resource.Container.NetworkSettings.IPAddress)
}
Error screenshot
The docker container info
$ docker ps | grep ethereum
03e1459341a8 ethereum/client-go:v1.10.15 "geth --dev --datadi…" 8 minutes ago Up 8 minutes 0.0.0.0:55020->8545/tcp, 0.0.0.0:55019->8546/tcp, 0.0.0.0:55006->30303/udp, 0.0.0.0:55018->30303/tcp serene_ardinghelli
Inside the container the command is
geth --dev --datadir /eth1data --ipcpath /eth1data/geth.ipc --http --http.addr 0.0.0.0 --http.api eth,net,web3,debug --ws --ws.addr 0.0.0.0
--verbosity 4
$ifconfig
eth0 Link encap:Ethernet HWaddr 02:42:AC:11:00:04
inet addr:172.17.0.4 Bcast:172.17.255.255 Mask:255.255.0.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2006 errors:0 dropped:0 overruns:0 frame:0
TX packets:1378 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2466217 (2.3 MiB) TX bytes:77013 (75.2 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:18 errors:0 dropped:0 overruns:0 frame:0
TX packets:18 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1073 (1.0 KiB) TX bytes:1073 (1.0 KiB)
$ telnet 172.17.0.4 8545
Connected to 172.17.0.4
Connection closed by foreign host
I think it's because of the wrong geth command, it's actually equivalent to using blew docker-compose.yml
to start a geth client, the container can get up, but inside the container, telnet 127.0.0.1 8545, doesn't work.
version: '2'
services:
geth:
image: ethereum/client-go:v1.10.15
command: --dev --datadir /eth1data --ipcpath /eth1data/geth.ipc --http --http.addr 0.0.0.0 --http.api eth,net,web3,debug --ws --ws.addr 0.0.0.0 --verbosity 4
ports:
- "30303:30303"
- "30303:30303/udp"
- "8545:8545"
I'm trying to use my private key from metamask but it returns wrong wallet address.
I'm using wallet.NewWalletFromPrivKey([]byte("privKey"))
example:
input:
0xa9059cbb0000000000000000000000003cd751e6b0078be393132286c442345e5dc496990000000000000000000000000000000000000000000000003b2118092395ec00
or
input:
[]byte{0x7c, 0x2, 0x52, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0……}
How to transaction decode and encode?
Can implement ethersjs on("pending",function())?
Hiya, was just playing with this library and of course the first thing I needed isn't implemented yet. :)
Opening an issue just to make sure it's tracked:
Also I suspect Transaction struct is missing the Hash field.
Otherwise looks like a great library, thanks for sharing it!
Currently we don't have statu
filed in Receipt.
We could use it to know whether the transction is successed if we support it.
Thanks!
Right now, the tracker starts from block 0. However, if there is an address on the filter, we can directly start on the block where that address was created so that we do not query blocks that we know for sure are empty.
Add CircleCi support.
wallet.NewWalletFromPrivKey will get a wrong wallet address, wallet.NewWalletFromMnemonic is correct.
// ParseTopic parses an individual topic
func ParseTopic(t *Type, topic web3.Hash) (interface{}, error) {
switch t.kind {
case KindBool:
if bytes.Equal(topic[:], topicTrue[:]) {
return true, nil
} else if bytes.Equal(topic[:], topicFalse[:]) {
return false, nil
}
return true, fmt.Errorf("is not a boolean")
case KindInt, KindUInt:
return readInteger(t, topic[:]), nil
case KindAddress:
return readAddr(topic[:])
//TODO: here we should add more types, i suppose.
//case KindFixedBytes:
//return readFixedBytes(t, topic[:])
default:
return nil, fmt.Errorf("Topic parsing for type %s not supported", t.String())
}
}
Add support for IPC transport.
Decode returns a nested interface object. It would be nice to do as go-ethereum does and provide the user with another method to unpack that interface into a struct. There would be two different methods:
func DecodeValues(input []byte) (interface{}, error)
func Decode(obj interface, input []byte) error
Type:0 is OK, Type:2 error
According to structs_marshal_rlp.go:MarshalRLPWith function
I add: Type, ChainID,MaxPriorityFeePerGas,MaxFeePerGas, delete GasPrice,
result:
{"code":-32000,"message":"invalid sender"}
//---------test---------------------------
web3 "github.com/umbracle/ethgo"
txn := &web3.Transaction{
To: &conAddr,
Value:big.NewInt(0),
//GasPrice: gasPrice,
Gas:90000,
Nonce:nonce,
Input:data,
Type:web3.TransactionDynamicFee, //2
ChainID: new(big.Int).SetInt64(137), //
MaxPriorityFeePerGas:new(big.Int).SetInt64(35000000000), // 35Gwei
MaxFeePerGas: new(big.Int).SetInt64(100000000000)} // 100Gwei
signer := wallet.NewEIP155Signer(137)
txn, _ = signer.SignTx(txn, key)
//LogStruct(&txn)
//sendData := txn.MarshalRLP()
sendData,err := txn.MarshalRLPTo(nil)
if(err != nil){
fmt.Println(err)
return
}
hash, err := Client.Eth().SendRawTransaction(sendData)
if(err != nil){
fmt.Println(err)
return
}
fmt.Println(hash)
hi, How do call this function w3.parity.traceBlock(14067789)
ABI should be able to parse tuples in string format like:
tuple(a int32, b int32, tuple(c []int32))
Right now the tests are only run for the http transport. It would be nice to run those tests for the other two transport protocols: ipc and websocket. We could do something like the t.Run function in the testing package that would return an addr from which create the Client. This way we only have to build once the test for each endpoint and it will be tested for each transport.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.