flow

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2025 License: MIT Imports: 10 Imported by: 0

README

flow-sdk

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

Installation

go get

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

go get -u github.com/724165435/go-wallet-sdk/coins/flow

Usage

New Account
	_, pubKey := GenerateKeyPair()
	payerAddr := "0b65ef5c755c9117"
	payerSequenceNumber := uint64(12)
	referenceBlockIDHex := "d83f8a740f774665016cbc34221fa1b1a0f430fe938297e2265afeee84bd19f4"
	gasLimit := uint64(9999)
	tx := CreateNewAccountTx(pubKey, payerAddr, referenceBlockIDHex, payerSequenceNumber, gasLimit)
	signPrivKeyHex := "986b514eec3705d809868611722574bba6d7829cb557dcbfea18b47b203321ed"
	signAddr := "0x0b65ef5c755c9117"
	err := SignTx(signAddr, signPrivKeyHex, tx)
	txBytes, err := core.TransactionToHTTP(*tx)
	if err != nil {
		// todo
	}
Transfer
	amount := float64(1)
	toAddr := "0x0b65ef5c755c9117"
	payer := "0x7a1fa92ef1acbe3c"
	referenceBlockIDHex := "5e62a0eb9505be3499fc321df3afc705f5483fd4409b940df3cabb66988117ce"
	payerSequenceNumber := uint64(2)
	gasLimit := uint64(9999)
	tx := CreateTransferFlowTx(amount, toAddr, payer, referenceBlockIDHex, payerSequenceNumber, gasLimit)
	signPrivKeyHex := "3eabec25b247b2f2e83dee958d77732a1a6a848383ac0dd9d4b0e97c18ee7259"
	signAddr := "0x7a1fa92ef1acbe3c"
	err := SignTx(signAddr, signPrivKeyHex, tx)
	txBytes, err := core.TransactionToHTTP(*tx)
	if err != nil {
		// todo
	}
Validate Address
    valid := ValidateAddress("0xa8d1a60acba12a20")

License

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

Documentation

Index

Constants

View Source
const DefaultAccountIndex = 0

Variables

This section is empty.

Functions

func CreateNewAccountTx

func CreateNewAccountTx(publicKeyHex, payer, referenceBlockIDHex string, payerSequenceNumber, gasLimit uint64) *core.Transaction

func CreateTransferFlowTx

func CreateTransferFlowTx(amount float64, toAddr, payer, referenceBlockIDHex string, payerSequenceNumber, gasLimit uint64) *core.Transaction

func CreateTx

func CreateTx(script, payer, referenceBlockIDHex string, args []string, payerSequenceNumber, gasLimit uint64) *core.Transaction

func DerivePublicKeyFromPrivate

func DerivePublicKeyFromPrivate(privateKeyHex string) (string, error)

DerivePublicKeyFromPrivate 根据私钥推导公钥(Flow格式)

func DerivePublicKeyFromPrivateBigInt

func DerivePublicKeyFromPrivateBigInt(privateKeyHex string) (string, error)

DerivePublicKeyFromPrivateBigInt 使用大整数操作的替代实现

func DerivePublicKeyFromPrivateBigIntRaw

func DerivePublicKeyFromPrivateBigIntRaw(privateKeyHex string) (string, error)

DerivePublicKeyFromPrivateBigIntRaw 使用大整数操作推导公钥(去掉0x04前缀)

func GenerateKeyPair

func GenerateKeyPair() (privKey, pubKey string)

func SignTx

func SignTx(signerAddr, privKeyHex string, tx *core.Transaction) error

func ValidateAddress

func ValidateAddress(address string) bool

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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