zil

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: 17 Imported by: 0

README

zil-sdk

Zil SDK is used to interact with the Zil 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/zil

Usage

New address
privHex := "c0dc46b9f9d6ef1c88dff3f1e82adc61cb11d77ab76a8d66338f14c2711cb4d8"
address, err := GetAddressFromPrivateKey(privHex)
New bech32 address
addr, err := FromBech32Addr("zil1h6j9d76cp997r3lenwmdzkzdemry9v9su5ddz8")
Sign transaction
privateKey := "c0dc46b9f9d6ef1c88dff3f1e82adc61cb11d77ab76a8d66338f14c2722cb4d8"
to := "zil1fwh4ltdguhde9s7nysnp33d5wye6uqpugufkz7"
gasPrice := "2000000000"
amount := big.NewInt(10000000000)
gasLimit := big.NewInt(50)
nonce := 2
chainId := 333
tx := CreateTransferTransaction(to, gasPrice, amount, gasLimit, nonce, chainId)
err := SignTransaction(privateKey, tx)
payload := tx.ToTransactionPayload()

License

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

Documentation

Overview

* Copyright (C) 2019 Zilliqa * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeTransactionProto

func EncodeTransactionProto(txParams txParams) ([]byte, error)

func FromBech32Addr

func FromBech32Addr(address string) (string, error)

func GetAddressFromPrivateKey

func GetAddressFromPrivateKey(privKeyHex string) (string, error)

func GetPublicKeyFromPrivateKey

func GetPublicKeyFromPrivateKey(privKeyHex string) (string, error)

func IsAddress

func IsAddress(address string) bool

func IsBech32

func IsBech32(addr string) bool

func IsByteString

func IsByteString(str string, len int) bool

func IsPrivateKey

func IsPrivateKey(private_key string) bool

func IsPublicKey

func IsPublicKey(public_key string) bool

func IsSignature

func IsSignature(signature string) bool

func SignTransaction

func SignTransaction(privateKeyhex string, tx *Transaction) error

func ToBech32Address

func ToBech32Address(address string) (string, error)

Types

type Init

type Init struct {
	Version   int           `json:"version"`
	Nonce     int           `json:"nonce"`
	ToAddr    string        `json:"toAddr"`
	Amount    int64         `json:"amount"`
	PubKey    string        `json:"pubKey"`
	GasPrice  int64         `json:"gasPrice"`
	GasLimit  int64         `json:"gasLimit"`
	Code      string        `json:"code"`
	Data      []interface{} `json:"data"`
	Signature string        `json:"signature"`
}

type Transaction

type Transaction struct {
	ID              string
	Version         string
	Nonce           string
	Amount          string
	GasPrice        string
	GasLimit        string
	Signature       string
	SenderPubKey    string
	ToAddr          string
	Code            string
	Data            interface{}
	ContractAddress string
	Priority        bool
}

func CreateTransferTransaction

func CreateTransferTransaction(to, gasPrice string, amount, gasLimit *big.Int, nonce int, chainId int) *Transaction

func (*Transaction) Bytes

func (t *Transaction) Bytes() ([]byte, error)

func (*Transaction) ToTransactionPayload

func (t *Transaction) ToTransactionPayload() TransactionPayload

type TransactionPayload

type TransactionPayload struct {
	Version   int    `json:"version"`
	Nonce     int    `json:"nonce"`
	ToAddr    string `json:"toAddr"`
	Amount    string `json:"amount"`
	PubKey    string `json:"pubKey"`
	GasPrice  string `json:"gasPrice"`
	GasLimit  string `json:"gasLimit"`
	Code      string `json:"code"`
	Data      string `json:"data"`
	Signature string `json:"signature"`
	Priority  bool   `json:"priority"`
}

Directories

Path Synopsis
* Copyright (C) 2019 Zilliqa * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version.
* Copyright (C) 2019 Zilliqa * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version.
* Copyright (C) 2019 Zilliqa * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version.
* Copyright (C) 2019 Zilliqa * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version.

Jump to

Keyboard shortcuts

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