Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/noot/go-relayer-client
client and CLI for submitting txs to go-relayer
https://github.com/noot/go-relayer-client
Last synced: about 2 months ago
JSON representation
client and CLI for submitting txs to go-relayer
- Host: GitHub
- URL: https://github.com/noot/go-relayer-client
- Owner: noot
- License: lgpl-3.0
- Created: 2022-09-24T11:02:25.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-03T04:12:40.000Z (about 2 years ago)
- Last Synced: 2024-11-12T11:41:20.255Z (about 2 months ago)
- Language: Go
- Size: 20.5 KB
- Stars: 2
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-relayer-client
Client library for [go-relayer](https://github.com/AthanorLabs/go-relayer), used for submitting transactions to the relayer.
## Requirements
- go1.18+
## Usage
```go
// ... code omitted
req := &common.SubmitTransactionRequest{
From: from,
To: to,
Value: big.NewInt(0),
Gas: big.NewInt(679639582),
Nonce: nonce,
Data: calldata,
}c := client.NewClient("http://localhost:8545")
resp, err := c.SubmitTransaction(req)
if err != nil {
panic(err)
}fmt.Println("sent tx to relayer: hash", resp.TxHash)
```For a full example, see `examples/main.go`.
### Run local example
The example in `examples/main.go` works with [go-relayer](https://github.com/AthanorLabs/go-relayer) locally.
To try it:
1. Install and run ganache:
```bash
npm i -g ganache
ganache --deterministic --accounts=50
```2. Clone and build `go-relayer`:
```bash
git clone https://github.com/AthanorLabs/go-relayer
cd go-relayer
make build
./bin/relayer --dev
```3. Clone and build `go-relayer-client`:
```bash
git clone https://github.com/AthanorLabs/go-relayer-client
cd go-relayer-client
make build
./bin/example
```You should see logs in the client as follows:
```bash
sent tx to relayer: hash 0xaaa5b2a84d1c4e4e5c251fe1ccb6059115267c6432d031615d20f5dae2771ddf
tx successful!
```You should see logs in the relayer as follows:
```bash
2022-09-29T14:08:03.117-0400 INFO cmd cmd/main.go:132 starting relayer with ethereum endpoint http://localhost:8545 and chain ID 1337
2022-09-29T14:08:03.232-0400 INFO cmd cmd/main.go:208 deployed MinimalForwarder.sol to 0xe78A0F7E598Cc8b0Bb87894B0F60dD2a88d6a8Ab
2022-09-29T14:08:03.233-0400 INFO rpc rpc/server.go:62 starting RPC server on http://localhost:7799
2022-09-29T14:08:16.685-0400 INFO relayer relayer/relayer.go:109 submitted transaction 0xaaa5b2a84d1c4e4e5c251fe1ccb6059115267c6432d031615d20f5dae2771ddf
```