Coder Social home page Coder Social logo

ethrpc's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ethrpc's Issues

EthGetBlockByNumber has first parameter of type INT

The EthGetBlockByNumber method has the first parameter of type INT.
The first parameter takes a block number.
In the future, this type will create problems with large numbers of blocks that are constantly increasing.
My advice is to use UINT64 or implement your own bigInt type.

Handling locked accounts

Disclaimer - I'm not super familiar with the Ethereum network

Trying to send a transaction on a private network with EthSendTransaction but getting the following error

Error -32000 (authentication needed: password or unlock)

Is there another function that I should be using that takes a password?

TransactionReceipt.Status throws with Parity

Parity returns status: null for transactions before Byzantium. Current code doesn't handle this and will throw calling strconv.ParseInt with null. Maybe we should change this field into *int.

Parity ref: https://wiki.parity.io/JSONRPC-eth-module#eth_gettransactionreceipt
Sample data:

{
	"jsonrpc": "2.0",
	"result": {
		"blockHash": "0xd99ad9a1142e57fbd0aea432bd76ef46c0af1ef71d80b6986b945fce95ce9d34",
		"blockNumber": "0x1e8485",
		"contractAddress": null,
		"cumulativeGasUsed": "0x16d15",
		"gasUsed": "0xc905",
		"logs": [
			{
				"address": "0xe0b7927c4af23765cb51314a0e0521a9645f0e2a",
				"blockHash": "0xd99ad9a1142e57fbd0aea432bd76ef46c0af1ef71d80b6986b945fce95ce9d34",
				"blockNumber": "0x1e8485",
				"data": "0x0000000000000000000000000000000000000000000000000000002e90edd000",
				"logIndex": "0x0",
				"topics": [
					"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
					"0x000000000000000000000000147af46ae9ccd18bb35ca01b353b51990e49dce1",
					"0x00000000000000000000000045d01cc478a3dcfd66607726dc50780f3eb4d7bc"
				],
				"transactionHash": "0x6994e58ca3816889184186ad8883e20277883959084c72a9fe12b92bea6422e2",
				"transactionIndex": "0x2",
				"transactionLogIndex": "0x0",
				"type": "mined"
			}
		],
		"logsBloom": "0x00000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000040000000008000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000400010000000000000000000000000000000000000000000000000000000000004000000000000000000800000000000000000000000000000000000000000000000000000000004000002000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000",
		"root": "0x5b694615e7e1ff4857d3c0714a4b70133ec2c161e1808029828ef979e5551347",
		"status": null,
		"transactionHash": "0x6994e58ca3816889184186ad8883e20277883959084c72a9fe12b92bea6422e2",
		"transactionIndex": "0x2"
	},
	"id": 1
}

Support IPC

It looks ethrpc (nice project!) doesn't support a local UNIX socket connection. Would it be possible to add IPC support?

Can you give me EthCall example

Summary

I love your tool. It is very convenient and easy to use. Can you give me an example of EthCall. I got error like the following. The below ethcall is for getting ERC20 token name with the contract address.

Steps to Reproduce

  1. run EthCall()
  • test.go
var client *ethrpc.EthRPC

func EthCall() string {
	result, err := client.EthCall(ethrpc.T{To: "0x41e5560054824ea6b0732e656e3ad64e20e94e45", Data: "0x06fdde03"}, "latest")
	if err != nil {
		panic(err)
	}
	return result
}

Expected Results

Return the result same as normal JSON RPC

$ curl -X POST --data '{"jsonrpc":"2.0","method":"eth_call","params":[{"to":"0x41e5560054824ea6b0732e656e3ad64e20e94e45","data":"0x06fdde03"}, "latest"],"id":83}' http://localhost:xxxx

{"jsonrpc":"2.0","id":83,"result":"0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000054369766963000000000000000000000000000000000000000000000000000000"}

Actual Results

Error occurred.

panic: Error -32602 (invalid argument 0: hex string has length 0, want 40 for common.Address)

EthGetBlockByHash always return response

Example:eth_getBlockByHash rpc call return null, if block was not found, which might happen when node is de-synchronised. In this case EthGetBlockByHash api method will return nil error, and empty response. Expected behaviour in this case would be return nil in response.

Error -32000 (authentication needed: password or unlock)

I think there is nothing wrong with the code below as I unlock the account first and then make transaction

package main

import (
	"fmt"
	"github.com/onrik/ethrpc"
	"log"
	"github.com/ethereum/go-ethereum/accounts/keystore"
	"github.com/ethereum/go-ethereum/accounts"
	"math/big"
)

func main() {
	client:=ethrpc.New("http://localhost:8545")
	_, err := client.Web3ClientVersion()
	if err != nil {
		log.Fatal("Error Connecting To Node : ",err)
	}
	ks := keystore.NewKeyStore(
		"/home/atif/.ethereum/rinkeby/keystore/",
		keystore.LightScryptN,
		keystore.LightScryptP)
	var unlockedAccount accounts.Account
	accs:=ks.Accounts()
	if err:=ks.Unlock(accs[1],"abcd");err==nil{
		unlockedAccount=accs[1]
		fmt.Println("Account Unlocked")
	}
	t:=ethrpc.T{
		From:  unlockedAccount.Address.Hex(),
		To:    "0x92dd679e2d8e107d8122ad5b3c868265e77c8af2",
		Gas:    123456,
		GasPrice:big.NewInt(12400000),
		Value:big.NewInt(20000000000),
		Data:"",
		Nonce:0,
	}
	txid, err := client.EthSendTransaction(t)
	if err != nil {
		log.Fatal("Transaction Error => ",err)
	}
	fmt.Println(txid)
}

What I want
txid of Real Transaction
What is get
Transaction Error => Error -32000 (authentication needed: password or unlock)

On Active Release of TCP Connections

TCP will not be released immediately after the end of the access, so when the client opens multiple threads to access at the same time, there will be an error of "onnectex: only one usage of each socket address (protocol/network address/port) is normally allowed." Can we adjust "TIME-WAIT"?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.