minter-go-sdk

module
v2.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2020 License: MIT

README

Minter Logo

go.dev reference

Overview

This is a pure Go SDK for working with Minter blockchain

Table of contents

Installing

go get github.com/MinterTeam/minter-go-sdk/v2

Minter API

Using API v2

go.dev reference

Using gRPC

go.dev reference

Using Transactions

go.dev reference

Sign transaction

Returns a signed tx.

⚠️ After sending the transaction, to make sure that the transaction was successfully committed on the blockchain, you need to find the transaction by hash and make sure that the status code is 0.

Single signature
Example
tx, _ := transaction.NewBuilder(transaction.TestNetChainID).NewTransaction(
    transaction.NewSendData().
        SetCoin(0).
        SetValue(big.NewInt(0).Mul(big.NewInt(1), big.NewInt(0).Exp(big.NewInt(10), big.NewInt(18), nil))).
        MustSetTo("Mx1b685a7c1e78726c48f619c497a07ed75fe00483"),
)

signedTransaction, _ := tx.
    SetGasPrice(1).
    SetGasCoin(0).
    SetNonce(1).
    Sign("07bc17abdcee8b971bb8723e36fe9d2523306d5ab2d683631693238e0f9df142")

encode, _ := signedTransaction.Encode()
Multi signatures
Example
tx, _ := transaction.NewBuilder(transaction.TestNetChainID).NewTransaction(
    transaction.NewSendData().
        SetCoin(0).
        SetValue(big.NewInt(0).Mul(big.NewInt(1), big.NewInt(0).Exp(big.NewInt(10), big.NewInt(18), nil))).
        MustSetTo("Mx1b685a7c1e78726c48f619c497a07ed75fe00483")
)

signedTx, _ := tx.SetNonce(1).SetGasPrice(1).SetGasCoin(0).SetSignatureType(transaction.SignatureTypeMulti).Sign(
    multisigAddress,
    "ae089b32e4e0976ca6888cb1023148bd1a9f1cc28c5d442e52e586754ff48d63",
    "b0a65cd84d57189b70d80fe0b3d5fa3ea6e02fa48041314a587a1f8fdba703d7",
    "4c8dbfb3258f383adf656c2131e5ed77ec482a36125db71fb49d29e0528ff2ba",
)

encode, _ := signedTx.Encode()

You can transfer the transaction to the remaining addresses

signedTx1, _ := tx.Sign(msigAddress, privateKey1)
encode, _ := signedTx.Encode()
// transfer encode transaction
signedTx1, _ = transaction.Decode(encode)
// and continue its signature by the remaining participants
signedTx12, _ := signedTx1.Sign(msigAddress, privateKey2)
signedTx123, _ := signedTx12.Sign(msigAddress, privateKey3)
encode, _ := signedTx123.Encode()

You can collect all signatures in one place without revealing the private key

signedTx1, _ := tx.Clone().Sign(msigAddress, "ae089b32e4e0976ca6888cb1023148bd1a9f1cc28c5d442e52e586754ff48d63")
signedTx2, _ := tx.Clone().Sign(msigAddress, "b0a65cd84d57189b70d80fe0b3d5fa3ea6e02fa48041314a587a1f8fdba703d7")
signedTx3, _ := tx.Clone().Sign(msigAddress, "4c8dbfb3258f383adf656c2131e5ed77ec482a36125db71fb49d29e0528ff2ba")
simpleSignatureData1, _ := signedTx1.SingleSignatureData()
simpleSignatureData2, _ := signedTx2.SingleSignatureData()
simpleSignatureData3, _ := signedTx3.SingleSignatureData()
signedTransaction, _ := tx.Clone().Sign(msigAddress)
signedTx123, _ := signedTransaction.AddSignature(simpleSignatureData1, simpleSignatureData2, simpleSignatureData3)

encode, _ := signedTx123.Encode()

Minter Wallet

go.dev reference

Directories

Path Synopsis
api
Package api ...
Package api ...
grpc_client
Package grpc_client is the interface for uses gRPC methods.
Package grpc_client is the interface for uses gRPC methods.
http_client
Package http_client is the interface for uses API v2 methods.
Package http_client is the interface for uses API v2 methods.
Transactions in Minter are RLP-encoded structures.
Transactions in Minter are RLP-encoded structures.
Wallet management assistants.
Wallet management assistants.

Jump to

Keyboard shortcuts

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