rockside

package module
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 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 (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)
rocksideIdentityAddress := common.HexToAddress("my_rockside_identity_hex_contract_address")
contractAddress := common.HexToAddress("my_contract_hex_address")

rocksideTransactor := rockside.NewTransactor(rocksideIdentityAddress, 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

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               *EOA
	Identities        *Identities
	Transaction       *Transactions
	RelayableIdentity *RelayableIdentity
	Tokens            *Tokens
	// 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, code, jsonABI string) (string, error)
Example
identities, err := rocksideClient.Identities.List()
if err != nil {
	panic(err)
}

var contractCode, jsonABI string
txHash, err := rocksideClient.DeployContractWithIdentity(identities[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 CreateTokenResponse

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

type EOA added in v0.0.12

type EOA endpoint

func (*EOA) Create added in v0.0.12

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

func (*EOA) List added in v0.0.12

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

type Identities added in v0.0.12

type Identities endpoint

func (*Identities) Create added in v0.0.12

func (i *Identities) Create() (createIdentitiesResponse, error)

func (*Identities) Exists added in v0.0.12

func (i *Identities) Exists(identityAddress common.Address) (bool, error)

func (*Identities) List added in v0.0.12

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

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 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 RelayableIdentity added in v0.0.12

type RelayableIdentity endpoint

func (*RelayableIdentity) Create added in v0.0.12

func (e *RelayableIdentity) Create(account string) (createRelayableIdentityResponse, error)

func (*RelayableIdentity) GetNonce added in v0.0.12

func (e *RelayableIdentity) GetNonce(contractAddress string, account string) (nonceResponse, error)

func (*RelayableIdentity) RelayExecute added in v0.0.12

func (e *RelayableIdentity) RelayExecute(contractAddress string, request RelayExecuteTxRequest) (relayTxResponse, error)

func (*RelayableIdentity) SignTxParams added in v0.0.12

func (b *RelayableIdentity) SignTxParams(privateKeyStr string, bouncerAddress string, signer string, destination string, value string, data string) (string, error)

type SendTxResponse

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

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) (CreateTokenResponse, 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 Transactions added in v0.0.12

type Transactions endpoint

func (*Transactions) Send added in v0.0.12

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

type Transactor

type Transactor struct {
	Transaction map[common.Hash]string
	// 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) 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