waves

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

README

waves-sdk

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

Usage

New address
pubKeyHash1, _ := crypto.NewPublicKeyFromBase58("2wySdbAsXi1bfAfMBKC1NcyyJemUWLM4R5ECwXJiADUx")
got, err := GetAddress(MainNetScheme, pubKeyHash1)
Transfer
p1 := "tMUA9XRwPTiUXCTmEvU6kFkqTFKxSpaAFvQwyAT29GR"
senderPublicKey, err := crypto.NewPublicKeyFromBase58(p1)
address, err := types.NewAddressFromString(a2)
waves := types.NewOptionalAssetWaves()
tx := NewUnsignedTransferWithSig(senderPublicKey, waves, waves, 1655401735758, 2000000,
    200000, types.NewRecipientFromAddress(address), []byte("attachment"))
// sign the tx
secretKey, err := crypto.NewSecretKeyFromBase58(s1)
if err := SignTransferWithSig(tx, secretKey); err != nil {
    return
}
idBytes, err := tx.ID.MarshalJSON()

License

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

Documentation

Index

Constants

View Source
const (
	// https://sourcegraph.com/github.com/wavesplatform/gowaves/-/blob/pkg/proto/addresses.go
	MainNetScheme   byte = 'W'
	TestNetScheme   byte = 'T'
	StageNetScheme  byte = 'S'
	CustomNetScheme byte = 'E'
)

account https://docs.waves.tech/en/blockchain/account/address

Variables

This section is empty.

Functions

func GenerateKeyPair

func GenerateKeyPair() (string, string, error)

GenerateKeyPair generates a new key pair.

func GetAddress

func GetAddress(scheme byte, pubKeyHash []byte) (string, error)

GetAddress returns the String WavesAddress from the public key. The scheme is one of the MainNetScheme, TestNetScheme, StageNetScheme or CustomNetScheme. The public key is the base58 encoded string of the public key.

func NewAddressFromBytes

func NewAddressFromBytes(b []byte) (types.WavesAddress, error)

NewAddressFromBytes creates an WavesAddress from the slice of bytes and checks that the result address is valid address.

func NewAddressFromString

func NewAddressFromString(s string) (types.WavesAddress, error)

NewAddressFromString creates an WavesAddress from its string representation. This function checks that the address is valid.

func NewUnsignedTransferWithSig

func NewUnsignedTransferWithSig(senderPK crypto.PublicKey, amountAsset, feeAsset types.OptionalAsset,
	timestamp, amount, fee uint64, recipient types.Recipient, attachment types.Attachment) *types.TransferWithSig

NewUnsignedTransferWithSig creates new TransferWithSig transaction without signature and ID.

func SignTransferWithSig

func SignTransferWithSig(t *types.TransferWithSig, privateKey crypto.SecretKey) error

func ValidAddress

func ValidAddress(addr string) (bool, error)

Types

This section is empty.

Directories

Path Synopsis
* MIT License
* MIT License
* MIT License
* MIT License
generated
* MIT License
* MIT License

Jump to

Keyboard shortcuts

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