oasis

package module
v0.0.0-...-61460eb Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 8 Imported by: 0

README

oasis-sdk

Oasis SDK is used to interact with the Oasis blockchain, it contains various functions can be used to web3 wallet.

Installation

go get

To obtain the latest version, simply require the project using :

go get -u github.com/okx/go-wallet-sdk/coins/oasis

Usage

New Address
	privateKeyHex := "a30a45ef8c019d22b7e8d18f11197677bff80ff4d2f23ab9ac14bdbac32c86e7baf40754ed3843e0464f814c3c605d8c36500cfb6892e2bd441839102f4200ed"
    address, err := NewAddress(privateKeyHex)
	if err != nil {
		// todo
	}
Transfer
	pk := "a30a45ef8c019d22b7e8d18f11197677bff80ff4d2f23ab9ac14bdbac32c86e7baf40754ed3843e0464f814c3c605d8c36500cfb6892e2bd441839102f4200ed"
	chainId := "b11b369e0da5bb230b220127f5e7b242d385ef8c6f54906243f30af63c815535"
	toAddr := "oasis1qqx0wgxjwlw3jwatuwqj6582hdm9rjs4pcnvzz66"
	amount := big.NewInt(100000000)
	feeAmount := big.NewInt(0)
	gas := uint64(2000)
	nonce := uint64(8)
	tx := NewTransferTx(nonce, gas, feeAmount, toAddr, amount)
	signedTx := SignTransaction(pk, chainId, tx)
	signedTxBytes, err := cbor.Marshal(signedTx)
	if err != nil {
		// todo
	}

License

Most packages or folder are MIT licensed, see package or folder for the respective license.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAddress

func NewAddress(privateKeyHex string) (string, error)

Types

type Fee

type Fee struct {
	// Amount is the fee amount to be paid.
	Amount []byte `json:"amount"`
	// Gas is the maximum gas that a transaction can use.
	Gas uint64 `json:"gas"`
}

Fee is the consensus transaction fee the sender wishes to pay for operations which require a fee to be paid to validators.

type Signature

type Signature struct {
	// PublicKey is the public key that produced the signature.
	PublicKey []byte `json:"public_key"`

	// Signature is the actual raw signature.
	Signature []byte `json:"signature"`
}

Signature is a signature, bundled with the signing public key.

type Signed

type Signed struct {
	// Blob is the signed blob.
	Blob []byte `json:"untrusted_raw_value"`

	// Signature is the signature over blob.
	Signature Signature `json:"signature"`
}

Signed is a signed blob.

type SignedTransaction

type SignedTransaction struct {
	Signed
}

SignedTransaction is a signed transaction.

func SignTransaction

func SignTransaction(privateKeyHex, chainId string, tx *Transaction) *SignedTransaction

type Transaction

type Transaction struct {
	// Nonce is a nonce to prevent replay.
	Nonce uint64 `json:"nonce"`
	// Fee is an optional fee that the sender commits to pay to execute this
	// transaction.
	Fee *Fee `json:"fee,omitempty"`

	// Method is the method that should be called.
	Method string `json:"method"`
	// Body is the method call body.
	Body interface{} `json:"body,omitempty"`
}

Transaction is an unsigned consensus transaction.

func NewTransferTx

func NewTransferTx(nonce, gas uint64, feeAmount *big.Int, toAddr string, amount *big.Int) *Transaction

func NewTx

func NewTx(nonce, gas uint64, feeAmount *big.Int, body interface{}) *Transaction

type Transfer

type Transfer struct {
	To     [21]byte `json:"to"`
	Amount []byte   `json:"amount"`
}

Transfer is a stake transfer.

Directories

Path Synopsis
Package cbor provides helpers for encoding and decoding canonical CBOR.
Package cbor provides helpers for encoding and decoding canonical CBOR.

Jump to

Keyboard shortcuts

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