iconsdk

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2024 License: MIT Imports: 20 Imported by: 0

README

ICONation logo

ICON SDK for Go

This is an SDK to communicate with the ICON blockchain, built for Go.

Disclaimer: I cannot guarantee optimal performance of this software. It is provided as is and without any assurances. Use it at your own risk.

Features

  • Wallet management
  • Read data from the blockchain
  • Send ICX transactions
  • Perform SCORE calls
  • Transaction builder

Testing

To run tests, ensure you have Go installed and run:

go test

Usage

import (
    "fmt"
    "github.com/mitsosf/icon-sdk-go"
)

iconservice := iconsdk.NewIconService(nil)
res, err := iconservice.GetBalance("<address>")
if err != nil {
    fmt.Println(err)
    return
}
fmt.Println(res)
	
// In case you want to initalize IconService on a testnet
iconServiceUrl := "https://lisbon.net.solidwallet.io/api/v3"
iconservice := iconsdk.NewIconService(&iconServiceUrl)

// Creating or loading a wallet
wallet := iconsdk.NewWallet(nil)
privateKey := "01234..."
wallet := iconsdk.NewWallet(&privateKey)

// IRC2
irc2 = iconsdk.NewIRC2("cx123...", *iconservice)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IRC2 added in v1.1.0

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

func NewIRC2 added in v1.1.0

func NewIRC2(contract string, iconService IconService) *IRC2

func (*IRC2) BalanceOf added in v1.1.0

func (i *IRC2) BalanceOf(address string) (map[string]interface{}, error)

func (*IRC2) Decimals added in v1.1.0

func (i *IRC2) Decimals() (map[string]interface{}, error)

func (*IRC2) Name added in v1.1.0

func (i *IRC2) Name() (map[string]interface{}, error)

func (*IRC2) Symbol added in v1.1.0

func (i *IRC2) Symbol() (map[string]interface{}, error)

func (*IRC2) TotalSupply added in v1.1.0

func (i *IRC2) TotalSupply() (map[string]interface{}, error)

func (*IRC2) Transfer added in v1.1.0

func (i *IRC2) Transfer(wallet Wallet, to string, value string, version string, nid string, nonce string, stepLimit string) (map[string]interface{}, error)

type IconService

type IconService struct {
	IconServiceURL string
}

func NewIconService

func NewIconService(iconServiceURL *string) *IconService

func (*IconService) Call

func (i *IconService) Call(score string, params map[string]interface{}) (map[string]interface{}, error)

func (*IconService) GetBalance

func (i *IconService) GetBalance(address string) (map[string]interface{}, error)

func (*IconService) GetBlockByHash

func (i *IconService) GetBlockByHash(hash string) (map[string]interface{}, error)

func (*IconService) GetBlockByHeight

func (i *IconService) GetBlockByHeight(height string) (map[string]interface{}, error)

func (*IconService) GetLastBlock

func (i *IconService) GetLastBlock() (map[string]interface{}, error)

func (*IconService) GetTransactionResult

func (i *IconService) GetTransactionResult(txHash string) (map[string]interface{}, error)

func (*IconService) SendTransaction

func (i *IconService) SendTransaction(wallet Wallet, to string, value string, version string, nid string, nonce string, stepLimit string) (map[string]interface{}, error)

func (*IconService) SendTransactionWithMessage

func (i *IconService) SendTransactionWithMessage(wallet Wallet, to string, value string, version string, nid string, nonce string, stepLimit string, message string) (map[string]interface{}, error)

type Transaction

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

func NewTransaction

func NewTransaction(iconService *IconService) *Transaction

func (*Transaction) Send

func (t *Transaction) Send() (map[string]interface{}, error)

func (*Transaction) SetMethod

func (t *Transaction) SetMethod(method string)

func (*Transaction) SetParams

func (t *Transaction) SetParams(newParams map[string]interface{})

type TransactionBuilder

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

func NewTransactionBuilder

func NewTransactionBuilder(iconService *IconService) *TransactionBuilder

func (*TransactionBuilder) Address

func (t *TransactionBuilder) Address(address string) *TransactionBuilder

func (*TransactionBuilder) BlockHash

func (t *TransactionBuilder) BlockHash(hash string) *TransactionBuilder

func (*TransactionBuilder) BlockHeight

func (t *TransactionBuilder) BlockHeight(height string) *TransactionBuilder

func (*TransactionBuilder) Build

func (t *TransactionBuilder) Build() Transaction

func (*TransactionBuilder) Call

func (t *TransactionBuilder) Call(call_params map[string]interface{}) *TransactionBuilder

func (*TransactionBuilder) From

func (*TransactionBuilder) Message

func (t *TransactionBuilder) Message(message string) *TransactionBuilder

func (*TransactionBuilder) Method

func (t *TransactionBuilder) Method(method string) *TransactionBuilder

func (*TransactionBuilder) Nid

func (*TransactionBuilder) Nonce

func (t *TransactionBuilder) Nonce(nonce string) *TransactionBuilder

func (*TransactionBuilder) Sign

func (t *TransactionBuilder) Sign(wallet Wallet) *TransactionBuilder

func (*TransactionBuilder) StepLimit

func (t *TransactionBuilder) StepLimit(stepLimit string) *TransactionBuilder

func (*TransactionBuilder) Timestamp

func (t *TransactionBuilder) Timestamp() *TransactionBuilder

func (*TransactionBuilder) To

func (*TransactionBuilder) TxHash

func (t *TransactionBuilder) TxHash(txHash string) *TransactionBuilder

func (*TransactionBuilder) Value

func (t *TransactionBuilder) Value(value string) *TransactionBuilder

func (*TransactionBuilder) Version

func (t *TransactionBuilder) Version(version string) *TransactionBuilder

type Wallet

type Wallet struct {
	PrivateKey    string
	PublicKey     string
	PublicAddress string
}

func NewWallet

func NewWallet(existingKey *string) *Wallet

Jump to

Keyboard shortcuts

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