rockside

package module
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 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!

(... or if you have GO locally do: go get github.com/rocksideio/rockside-sdk-go/cmd/rockside)

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 identities ls

For instance you can deploy a contract with:

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

Other useful commands:

# List my identities
rockside --testnet identities ls

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

Documentation

Overview

Example (ContractReadCallUsingContractABIBindings)
contractAddress := common.HexToAddress("my_contract_address")
contract, err := NewContractCaller(contractAddress, rocksideClient.RPCClient)
if err != nil {
	panic(err)
}

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

Example (GaslessContractWriteCallUsingContractABIBindings)
rocksideIdentityAddress := common.HexToAddress("my_rockside_identity_contract_address")
contractAddress := common.HexToAddress("my_contract_address")

rocksideTransactor := rockside.NewTransactor(rocksideIdentityAddress, rocksideClient)
contract, err := NewContractTransactor(contractAddress, rocksideTransactor)
if err != nil {
	panic(err)
}

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

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

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func TransactOpts

func TransactOpts() *bind.TransactOpts

Types

type Client

type Client struct {
	RPCClient *RPCClient

	EOA               *eoaEndpoint
	Identities        *identitiesEndpoint
	Transaction       *transactionEndpoint
	RelayableIdentity *relayableIdentityEndpoint
	Tokens            *tokensEndpoint
	// contains filtered or unexported fields
}

func NewClient

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

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

func (*Client) CurrentNetwork

func (c *Client) CurrentNetwork() Network

func (*Client) DeployContractWithIdentity

func (c *Client) DeployContractWithIdentity(rocksideIdentityAddr string, code, jsonABI string) (string, error)

func (*Client) SetLogger

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

func (*Client) URL

func (c *Client) URL() string

type CreateEOAResponse

type CreateEOAResponse struct {
	Address string `json:"address"`
}

type CreateIdentitiesResponse

type CreateIdentitiesResponse struct {
	Address         string `json:"address"`
	TransactionHash string `json:"transaction_hash"`
}

type CreateRelayableIdentityResponse

type CreateRelayableIdentityResponse struct {
	Address         string `json:"address"`
	TransactionHash string `json:"transaction_hash"`
}

type CreateTokenResponse

type CreateTokenResponse struct {
	Token string `json:"token"`
}

type Network

type Network string
var (
	Testnet Network = "ropsten"
	Mainnet Network = "mainnet"
)

func (Network) ChainID

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

func (Network) EtherscanURL

func (n Network) EtherscanURL() string

type NonceResponse

type NonceResponse struct {
	Nonce string `json:"nonce"`
}

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) SendTransactionFromIdentity

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

type RelayExecuteTxRequest

type RelayExecuteTxRequest struct {
	From      string `json:"from"`
	To        string `json:"to"`
	Value     string `json:"value"`
	Data      string `json:"data"`
	Signature string `json:"signature"`
}

type RelayTxResponse

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

type SendTxResponse

type SendTxResponse struct {
	TransactionHash string `json:"transaction_hash"`
}

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"`
}

func (Transaction) ValidateFields

func (t Transaction) ValidateFields() error

type Transactor

type Transactor struct {
	// contains filtered or unexported fields
}

func NewTransactor

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

func (*Transactor) EstimateGas

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

func (*Transactor) LookupRocksideTransactionHash

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

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) 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