Documentation ¶
Overview ¶
Package near allows to interact with the NEAR platform via RPC calls.
Index ¶
- Variables
- func GetTransactionLastResult(txResult map[string]interface{}) (interface{}, error)
- type AccessKey
- type AccessKeyPermission
- type Account
- func (a *Account) CreateAccount(newAccountID string, publicKey utils.PublicKey, amount big.Int) (map[string]interface{}, error)
- func (a *Account) DeleteAccount(beneficiaryID string) (map[string]interface{}, error)
- func (a *Account) FunctionCall(contractID, methodName string, args []byte, gas uint64, amount big.Int) (map[string]interface{}, error)
- func (a *Account) SendMoney(receiverID string, amount big.Int) (map[string]interface{}, error)
- func (a *Account) SignAndSendTransaction(receiverID string, actions []Action) (map[string]interface{}, error)
- func (a *Account) SignTransaction(receiverID string, actions []Action) (txHash []byte, signedTx *SignedTransaction, err error)
- type Action
- type AddKey
- type Config
- type Connection
- func (c *Connection) Block() (map[string]interface{}, error)
- func (c *Connection) GetAccountState(accountID string) (map[string]interface{}, error)
- func (c *Connection) GetContractCode(accountID string) (map[string]interface{}, error)
- func (c *Connection) GetNodeStatus() (map[string]interface{}, error)
- func (c *Connection) SendTransaction(signedTransaction []byte) (map[string]interface{}, error)
- func (c *Connection) SendTransactionAsync(signedTransaction []byte) (string, error)
- func (c *Connection) ViewAccessKey(accountID, publicKey string) (map[string]interface{}, error)
- func (c *Connection) ViewAccessKeyList(accountID string) (map[string]interface{}, error)
- type DeleteAccount
- type DeleteKey
- type DeployContract
- type FunctionCall
- type FunctionCallPermission
- type Signature
- type SignedTransaction
- type Stake
- type Transaction
- type Transfer
Constants ¶
This section is empty.
Variables ¶
var ErrNotObject = errors.New("near: JSON-RPC result is not an object")
ErrNotObject is returned if a result is not an object, but should be.
var ErrNotString = errors.New("near: JSON-RPC result is not a string")
ErrNotString is returned if a result is not a string, but should be.
Functions ¶
func GetTransactionLastResult ¶
GetTransactionLastResult decodes the last transaction result from a JSON map and tries to deterimine if we have an error condition.
Types ¶
type AccessKey ¶
type AccessKey struct { Nonce uint64 Permission AccessKeyPermission }
AccessKey encodes a NEAR access key.
type AccessKeyPermission ¶
type AccessKeyPermission struct { Enum borsh.Enum `borsh_enum:"true"` // treat struct as complex enum when serializing/deserializing FunctionCall FunctionCallPermission FullAccess borsh.Enum }
AccessKeyPermission encodes a NEAR access key permission.
type Account ¶
type Account struct {
// contains filtered or unexported fields
}
Account defines access credentials for a NEAR account.
func LoadAccount ¶
func LoadAccount(c *Connection, cfg *Config, receiverID string) (*Account, error)
LoadAccount loads the credential for the receiverID account, to be used via connection c, and returns it.
func (*Account) CreateAccount ¶
func (a *Account) CreateAccount( newAccountID string, publicKey utils.PublicKey, amount big.Int, ) (map[string]interface{}, error)
CreateAccount creates the newAccountID with the given publicKey and amount.
func (*Account) DeleteAccount ¶
DeleteAccount deletes the account and sends the remaining Ⓝ balance to the account beneficiaryID.
func (*Account) FunctionCall ¶
func (a *Account) FunctionCall( contractID, methodName string, args []byte, gas uint64, amount big.Int, ) (map[string]interface{}, error)
FunctionCall performs a NEAR function call.
func (*Account) SignAndSendTransaction ¶
func (a *Account) SignAndSendTransaction( receiverID string, actions []Action, ) (map[string]interface{}, error)
SignAndSendTransaction signs the given actions and sends them as a transaction to receiverID.
func (*Account) SignTransaction ¶
type Action ¶
type Action struct { Enum borsh.Enum `borsh_enum:"true"` // treat struct as complex enum when serializing/deserializing CreateAccount borsh.Enum DeployContract DeployContract FunctionCall FunctionCall Transfer Transfer Stake Stake AddKey AddKey DeleteKey DeleteKey DeleteAccount DeleteAccount }
Action simulates an enum for Borsh encoding.
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection allows to do JSON-RPC to a NEAR endpoint.
func NewConnection ¶
func NewConnection(nodeURL string) *Connection
NewConnection returns a new connection for JSON-RPC calls to the NEAR endpoint with the given nodeURL.
func NewConnectionWithTimeout ¶
func NewConnectionWithTimeout(nodeURL string, timeout time.Duration) *Connection
NewConnectionWithTimeout returns a new connection for JSON-RPC calls to the NEAR endpoint with the given nodeURL with the given timeout.
func (*Connection) Block ¶
func (c *Connection) Block() (map[string]interface{}, error)
Block queries network and returns latest block.
For details see https://docs.near.org/docs/interaction/rpc#block
func (*Connection) GetAccountState ¶
func (c *Connection) GetAccountState(accountID string) (map[string]interface{}, error)
GetAccountState returns basic account information for given accountID.
For details see https://docs.near.org/docs/api/rpc/contracts#view-account
func (*Connection) GetContractCode ¶
func (c *Connection) GetContractCode(accountID string) (map[string]interface{}, error)
GetContractCode returns the contract code (Wasm binary) deployed to the account.
For details see https://docs.near.org/docs/api/rpc/contracts#view-contract-code
func (*Connection) GetNodeStatus ¶
func (c *Connection) GetNodeStatus() (map[string]interface{}, error)
GetNodeStatus returns general status of a given node.
For details see https://docs.near.org/docs/api/rpc/network#node-status
func (*Connection) SendTransaction ¶
func (c *Connection) SendTransaction(signedTransaction []byte) (map[string]interface{}, error)
SendTransaction sends a signed transaction and waits until the transaction is fully complete. Has a 10 second timeout.
For details see https://docs.near.org/docs/develop/front-end/rpc#send-transaction-await
func (*Connection) SendTransactionAsync ¶
func (c *Connection) SendTransactionAsync(signedTransaction []byte) (string, error)
SendTransactionAsync sends a signed transaction and immediately returns a transaction hash.
For details see https://docs.near.org/docs/develop/front-end/rpc#send-transaction-async
func (*Connection) ViewAccessKey ¶
func (c *Connection) ViewAccessKey(accountID, publicKey string) (map[string]interface{}, error)
ViewAccessKey returns information about a single access key for given accountID and publicKey. The publicKey must have a signature algorithm prefix (like "ed25519:").
For details see https://docs.near.org/docs/develop/front-end/rpc#view-access-key
func (*Connection) ViewAccessKeyList ¶
func (c *Connection) ViewAccessKeyList(accountID string) (map[string]interface{}, error)
ViewAccessKeyList returns all access keys for the given accountID.
For details see https://docs.near.org/docs/api/rpc/access-keys#view-access-key-list
type FunctionCall ¶
The FunctionCall action.
type FunctionCallPermission ¶
FunctionCallPermission encodes a NEAR function call permission (an access key permission).
type SignedTransaction ¶
type SignedTransaction struct { Transaction Transaction Signature Signature }
SignedTransaction encodes signed transactions for NEAR.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
nearcall
nearcall allows to send large encoded arguments to a contract method.
|
nearcall allows to send large encoded arguments to a contract method. |
nearkey
nearkey generates a near node/account/validator key.
|
nearkey generates a near node/account/validator key. |
Package keystore implements an unencrypted file system key store.
|
Package keystore implements an unencrypted file system key store. |
Package utils implements helper functions for the Go NEAR API.
|
Package utils implements helper functions for the Go NEAR API. |