Skip to content

risechain/luban-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Golang client for Luban's Taiyi gateway

This repo is a collection of things to work with Taiyi gateway in Golang.

Modules

This repo, consists of several go modules:

import (
  "github.com/risechain/luban-api/client"
  "github.com/risechain/luban-api/types"
)

cl := client.NewClient(gatewayUrl, privateKey)
slots, _ := cl.GetSlots(ctx)
slot := slots[0].Slot
gasFee, blobFee, _ := cl.GetPreconfFee(ctx)
id, _ := cl.ReserveBlockspace(ctx, types.ReserveBlockSpaceRequest{
  GasLimit: tx.Gas(),
  BlobCount: 0,
  TargetSlot: slot,
  Deposit: /* SNIP, basically { gas_limit * gas_fee + blob_count * blob_gas_fee } * 0.5 */
  Tip: /* SNIP, basically { gas_limit * gas_fee + blob_count * blob_gas_fee } * 0.5 */
})
cl.SubmitTransaction(ctx, id, tx)
import (
  "github.com/ethereum/go-ethereum/accounts/abi/bind"
  "github.com/risechain/luban-api/escrow"
)

escrow := escrow.NewEscrow(escrowAddr, rpc)
balance, _ := escrow.BalanceOf(&bind.CallOpts{Context: t.ctx}, ourAddr)

opts, _ := bind.NewKeyedTransactorWithChainID(privateKey, chainId)
opts.Value = 1000000000000000000 // 1 Eth
deposit, _ := escrow.Deposit(opts)
rpc.SendTransaction(ctx, deposit)
import (
  "github.com/risechain/luban-api/client"
  "github.com/risechain/luban-api/types"
  "github.com/risechain/luban-api/txmgr"
)

preconfer := client.NewClient(...)
cfg := &txmgr.Config{
	From:           addr,
	NetworkTimeout: time.Second,
	Signer: /*SNIP*/,
}
txmgr := txmgr.NewPreconfTxMgr(logger, rpc, cfg, preconfer)

cand := txmgr.TxCandidate{/*SNIP*/}
receipt, _ := txmanager.Send(ctx, cand)

About

Golang client for Luban's Taiyi gateway

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy