rockside

package module
v0.0.36 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2020 License: MIT Imports: 25 Imported by: 0

README

GoDoc

Rockside GO SDK

Official Rockside SDK for GO applications.

Client Library Usage

To use the client look at the reference and examples

Command Line Interface Usage

To interact with the Rockside API, deploy contracts, etc. we provide a CLI (that uses the Rockside SDK GO)

Install

Get the latest CLI binary for macOS, Windows or Linux here!

If you have GO locally do: go get github.com/rocksideio/rockside-sdk-go/cmd/rockside

To build from the cloned repo do: go build ./cmd/rockside/; ./rockside -h

Usage

Display the various commands & flags available with:

rockside -h

Then to use commands export your API key:

export ROCKSIDE_API_KEY=...
rockside --tesnet --verbose smartwallets ls

For instance you can deploy a contract with:

export ROCKSIDE_API_KEY=...
rockside --testnet deploy-contract /tmp/mycontract.sol

Display/track a transaction:

# Show a transaction using its hash
rockside transaction show 0x73da8b72acf620c05471edded3e425e853b6ad6853b8fcfd6adf754fff4bce9b

# Show a transaction using its tracking ID
rockside transaction show 01B7J50J5N7PEFMCY181N32938

Other useful commands:

# List my smart wallets
rockside --testnet smartwallets ls

# Show a transaction receipt from a transaction hash
rockside --testnet receipt 0x97dfce42248a3f67f5a0660fab117b0ed7cb57af799bdda8854eca5ae5a98e28

Documentation

Overview

Example (ContractCaller)
contractAddress := common.HexToAddress("my_contract_address")

// NewContractCaller is typically in your contract binding GO file which was generated via `abigen`
contract, err := NewContractCaller(contractAddress, rocksideClient.RPCClient)
if err != nil {
	panic(err)
}

timestamp, _ := contract.Read(&bind.CallOpts{}, [32]byte{})
fmt.Println(timestamp)
Output:

Example (GaslessContractTransactor)
rocksideSmartWalletAddress := common.HexToAddress("my_rockside_smartwallet_hex_contract_address")
contractAddress := common.HexToAddress("my_contract_hex_address")

rocksideTransactor := rockside.NewTransactor(rocksideSmartWalletAddress, rocksideClient)

// NewContractTransactor is typically in your contract binding GO file which was generated via `abigen`
contract, err := NewContractTransactor(contractAddress, rocksideTransactor)
if err != nil {
	panic(err)
}

tx, _ := contract.Write(rockside.TransactOpts(), [32]byte{})

txHash := rocksideTransactor.ReturnRocksideTransactionHash(tx.Hash())
fmt.Println(txHash)
Output:

Index

Examples

Constants

View Source
const (
	SmartWalletABI = `` /* 4021-byte string literal not displayed */
)

Variables

This section is empty.

Functions

func GetHash added in v0.0.33

func GetHash(signer, destination common.Address, data []byte, nonce *big.Int, forwarder common.Address, chainID *big.Int) ([]byte, error)

func TransactOpts

func TransactOpts() *bind.TransactOpts

Types

type Client

type Client struct {
	RPCClient *RPCClient

	EOA          *EOA
	SmartWallets *SmartWallets
	Transaction  *Transactions
	Tokens       *Tokens
	Forwarder    *Forwarder
	Relay        *Relay
	// contains filtered or unexported fields
}

func NewClientFromAPIKey added in v0.0.14

func NewClientFromAPIKey(apiKey string, net Network, rocksideBaseURL ...string) (*Client, error)
Example
rocksideAPIclient, err := rockside.NewClientFromAPIKey(os.Getenv("ROCKSIDE_API_KEY"), rockside.Testnet)
if err != nil {
	panic(err)
}

smartWallets, err := rocksideAPIclient.SmartWallets.List()
if err != nil {
	panic(err)
}
fmt.Println(smartWallets)
Output:

func NewClientFromToken added in v0.0.14

func NewClientFromToken(token, origin string, net Network, rocksideBaseURL ...string) (*Client, error)
Example
rocksideAPIclient, err := rockside.NewClientFromToken("token", "example.com", rockside.Testnet)
if err != nil {
	panic(err)
}

smartWallets, err := rocksideAPIclient.SmartWallets.List()
if err != nil {
	panic(err)
}
fmt.Println(smartWallets)
Output:

func (*Client) CurrentNetwork

func (c *Client) CurrentNetwork() Network

func (*Client) DeployContractWithSmartWallet added in v0.0.27

func (c *Client) DeployContractWithSmartWallet(rocksideSmartWalletAddr, code, jsonABI string) (string, error)
Example
smartWallets, err := rocksideClient.SmartWallets.List()
if err != nil {
	panic(err)
}

var contractCode, jsonABI string
txHash, err := rocksideClient.DeployContractWithSmartWallet(smartWallets[0], contractCode, jsonABI)
if err != nil {
	panic(err)
}
fmt.Println(txHash)
Output:

func (*Client) SetLogger

func (c *Client) SetLogger(l *log.Logger)

func (*Client) URL

func (c *Client) URL() string

type ContractCreationResponse added in v0.0.27

type ContractCreationResponse struct {
	TransactionResponse
	// contains filtered or unexported fields
}

type EOA added in v0.0.12

type EOA endpoint

func (*EOA) Create added in v0.0.12

func (e *EOA) Create() (addressResponse, error)

func (*EOA) List added in v0.0.12

func (e *EOA) List() ([]string, error)

func (*EOA) SignMessage added in v0.0.22

func (e *EOA) SignMessage(address string, message SignMessageRequest) (string, error)

func (*EOA) SignTransaction added in v0.0.22

func (e *EOA) SignTransaction(address string, transaction SignTransactionRequest) (string, error)

type Forwarder added in v0.0.25

type Forwarder endpoint

func (*Forwarder) Create added in v0.0.25

func (e *Forwarder) Create(owner string) (ContractCreationResponse, error)

func (*Forwarder) Get added in v0.0.25

func (e *Forwarder) Get() ([]string, error)

func (*Forwarder) GetRelayParams added in v0.0.25

func (e *Forwarder) GetRelayParams(forwarderAddress string, account string, channels ...string) (paramsResponse, error)

func (*Forwarder) Relay added in v0.0.25

func (e *Forwarder) Relay(forwarderAddress string, request RelayExecuteTxRequest) (RelayTxResponse, error)

func (*Forwarder) SignTxParams added in v0.0.25

func (e *Forwarder) SignTxParams(privateKeyStr, forwarder, signer, destination, data, nonce string) (string, error)

type Network

type Network string
var (
	Testnet           Network = "ropsten"
	Mainnet           Network = "mainnet"
	PoaNetworkMainnet Network = "poanetwork"
	GethPrivateNet    Network = "gethprivate"
)

func (Network) ChainID

func (n Network) ChainID() *big.Int

func (Network) ExplorerURL added in v0.0.14

func (n Network) ExplorerURL() string

type RPCClient

type RPCClient struct {
	*ethclient.Client
	// contains filtered or unexported fields
}
Example
// Get a RPC client from your existing Rockside client.
rpc := rocksideClient.RPCClient

accounts, err := rpc.EthAccounts()
if err != nil {
	panic(err)
}
fmt.Println(accounts)

balance, err := rpc.BalanceAt(context.Background(), common.Address{}, nil)
if err != nil {
	panic(err)
}
fmt.Println(balance)
Output:

func (*RPCClient) EthAccounts

func (r *RPCClient) EthAccounts() ([]string, error)

func (*RPCClient) SendRocksideTransaction added in v0.0.15

func (r *RPCClient) SendRocksideTransaction(tx Transaction) (string, error)

func (*RPCClient) SendTransactionFromSmartWallet added in v0.0.27

func (r *RPCClient) SendTransactionFromSmartWallet(tx Transaction) (string, error)

type Relay added in v0.0.34

type Relay endpoint

func (*Relay) GetParams added in v0.0.34

func (e *Relay) GetParams(destination string) (RelayParamsResponse, error)

func (*Relay) Relay added in v0.0.34

func (e *Relay) Relay(destination string, request RelayTx) (RelayTxResponse, error)

type RelayExecuteTxMessage added in v0.0.29

type RelayExecuteTxMessage struct {
	Signer string `json:"signer"`
	To     string `json:"to"`
	Data   string `json:"data"`
	Nonce  string `json:"nonce"`
}

type RelayExecuteTxRequest

type RelayExecuteTxRequest struct {
	Speed         string                `json:"speed"`
	GasPriceLimit string                `json:"gas_price_limit"`
	Message       RelayExecuteTxMessage `json:"message"`
	Signature     string                `json:"signature"`
	Gas           string                `json:"gas"`
}

type RelayParamsResponse added in v0.0.25

type RelayParamsResponse struct {
	Speeds map[string]SpeedInfo `json:"speeds"`
}

type RelayTx added in v0.0.34

type RelayTx struct {
	Data  string `json:"data"`
	Speed string `json:"speed"`
}

type RelayTxResponse

type RelayTxResponse struct {
	TransactionHash string `json:"transaction_hash"`
	TrackingID      string `json:"tracking_id"`
}

type SignMessageRequest added in v0.0.22

type SignMessageRequest struct {
	Message string `json:"message"`
}

type SignTransactionRequest added in v0.0.22

type SignTransactionRequest struct {
	Transaction
	NetworkID string `json:"network_id"`
}

type SmartWallets added in v0.0.27

type SmartWallets endpoint

func (*SmartWallets) Create added in v0.0.27

func (i *SmartWallets) Create(account, forwarder string) (ContractCreationResponse, error)

func (*SmartWallets) Exists added in v0.0.27

func (i *SmartWallets) Exists(smartWalletAddr common.Address) (bool, error)

func (*SmartWallets) List added in v0.0.27

func (i *SmartWallets) List() ([]string, error)

type SpeedInfo added in v0.0.35

type SpeedInfo struct {
	GasPrice string `json:"gas_price"`
	Relayer  string `json:"relayer"`
}

type Tokens added in v0.0.12

type Tokens endpoint

func (*Tokens) Create added in v0.0.12

func (i *Tokens) Create(domain string, contracts []string) (tokenResponse, error)

func (*Tokens) CreateForEndUser added in v0.0.17

func (i *Tokens) CreateForEndUser(domain string, endUserID string, contracts []string) (tokenResponse, error)

type Transaction

type Transaction struct {
	From     string `json:"from,omitempty"`
	To       string `json:"to,omitempty"`
	Value    string `json:"value,omitempty"`
	Data     string `json:"data,omitempty"`
	Nonce    string `json:"nonce,omitempty"`
	Gas      string `json:"gas,omitempty"`
	GasPrice string `json:"gasprice,omitempty"`
}

type TransactionResponse added in v0.0.27

type TransactionResponse struct {
	TransactionHash string `json:"transaction_hash"`
	TrackingID      string `json:"tracking_id"`
}

type Transactions added in v0.0.12

type Transactions endpoint

func (*Transactions) Send added in v0.0.12

func (t *Transactions) Send(transaction Transaction) (ContractCreationResponse, error)

func (*Transactions) Show added in v0.0.21

func (t *Transactions) Show(txHashOrTrackingID string) (interface{}, error)

type Transactor

type Transactor struct {
	Transaction map[common.Hash]string
	// contains filtered or unexported fields
}

func NewTransactor

func NewTransactor(rocksideSmartWallet common.Address, client *Client) *Transactor

func (*Transactor) EstimateGas

func (t *Transactor) EstimateGas(ctx context.Context, call ethereum.CallMsg) (gas uint64, err error)

func (*Transactor) PendingCodeAt

func (t *Transactor) PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)

func (*Transactor) PendingNonceAt

func (t *Transactor) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)

func (*Transactor) ReturnRocksideTransactionHash added in v0.0.10

func (t *Transactor) ReturnRocksideTransactionHash(hash common.Hash) string

func (*Transactor) SendTransaction

func (t *Transactor) SendTransaction(ctx context.Context, tx *types.Transaction) error

func (*Transactor) SuggestGasPrice

func (t *Transactor) SuggestGasPrice(ctx context.Context) (*big.Int, error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL