concordium

package module
v0.0.0-...-ae2c35d Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

README

Concordium GoLang Client Library


Installation

go get -u github.com/Concordium/concordium-go-sdk

Main Client usage

PeerConnect
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.PeerConnect(ctx, "127.0.0.1", 10001)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%t\n", r)
}
PeerDisconnect
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.PeerDisconnect(ctx, "127.0.0.1", 10001)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%t\n", r)
}
PeerUptime
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.PeerUptime(ctx)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%d\n", r)
}
PeerTotalSent
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.PeerTotalSent(ctx)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%d\n", r)
}
PeerTotalReceived
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.PeerTotalReceived(ctx)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%d\n", r)
}
PeerVersion
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.PeerVersion(ctx)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%s\n", r)
}
PeerStats
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.PeerStats(ctx, true)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", r)
}
PeerList
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.PeerList(ctx, true)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", r)
}
BanNode
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.BanNode(ctx, &concordium.PeerElement{
		NodeId:        concordium.NodeId(0),
		Ip:            "127.0.0.1",
		Port:          10001,
		CatchupStatus: concordium.PeerElementCatchupStatus(0),
	})
	if err != nil {
		panic(err)
	}
	fmt.Printf("%t\n", r)
}
UnbanNode
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.UnbanNode(ctx, &concordium.PeerElement{
		NodeId:        "85d72ab53b6cd728",
		Ip:            "127.0.0.1",
		Port:          10001,
		CatchupStatus: concordium.PeerElementCatchupStatus(0),
	})
	if err != nil {
		panic(err)
	}
	fmt.Printf("%t\n", r)
}
JoinNetwork
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.JoinNetwork(ctx, concordium.DefaultNetworkId)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%t\n", r)
}
LeaveNetwork
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.LeaveNetwork(ctx, concordium.DefaultNetworkId)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%t\n", r)
}
NodeInfo
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.NodeInfo(ctx)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", r)
}
GetConsensusStatus
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.GetConsensusStatus(ctx)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", r)
}
GetBlockInfo
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.GetBlockInfo(ctx, "63ced0f4b0ad467f3abee79f8e8c8c891c0676ee58c1b79ab2f5a383818d0ebc")
	if err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", r)
}
GetAncestors
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.GetAncestors(ctx, "63ced0f4b0ad467f3abee79f8e8c8c891c0676ee58c1b79ab2f5a383818d0ebc", 10)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", r)
}
GetBranches
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.GetBranches(ctx)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", r)
}
GetBlocksAtHeight
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.GetBlocksAtHeight(ctx, 3335584)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", r)
}
StartBaker
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.StartBaker(ctx)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%t\n", r)
}
StopBaker
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.StopBaker(ctx)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%t\n", r)
}
GetAccountList
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.GetAccountList(ctx, "63ced0f4b0ad467f3abee79f8e8c8c891c0676ee58c1b79ab2f5a383818d0ebc")
	if err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", r)
}
GetInstances
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.GetInstances(ctx, "63ced0f4b0ad467f3abee79f8e8c8c891c0676ee58c1b79ab2f5a383818d0ebc")
	if err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", r)
}
GetAccountInfo
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.GetAccountInfo(ctx,
		"63ced0f4b0ad467f3abee79f8e8c8c891c0676ee58c1b79ab2f5a383818d0ebc",
		"3TdFQK6hqoqoW38JQJGZ2y3RZfgVPzwB7dMKXbBdeYvdwPeF63",
	)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", r)
}
GetInstanceInfo
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.GetInstanceInfo(ctx,
		"63ced0f4b0ad467f3abee79f8e8c8c891c0676ee58c1b79ab2f5a383818d0ebc",
		&concordium.ContractAddress{Index: 5129, SubIndex: 0},
	)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", r)
}
InvokeContract
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.InvokeContract(ctx, "63ced0f4b0ad467f3abee79f8e8c8c891c0676ee58c1b79ab2f5a383818d0ebc", &concordium.ContractContext{
		Invoker:   concordium.WrapAccountAddress("3TdFQK6hqoqoW38JQJGZ2y3RZfgVPzwB7dMKXbBdeYvdwPeF63"),
		Contract:  &concordium.ContractAddress{Index: 5129, SubIndex: 0},
		Amount:    concordium.NewAmountZero(),
		Method:    "a.func",
		Parameter: "",
		Energy:    10000000,
	})
	if err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", r)
}
GetRewardStatus
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.GetRewardStatus(ctx, "63ced0f4b0ad467f3abee79f8e8c8c891c0676ee58c1b79ab2f5a383818d0ebc")
	if err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", r)
}
GetBirkParameters
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.GetBirkParameters(ctx, "63ced0f4b0ad467f3abee79f8e8c8c891c0676ee58c1b79ab2f5a383818d0ebc")
	if err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", r)
}
GetModuleList
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.GetModuleList(ctx, "63ced0f4b0ad467f3abee79f8e8c8c891c0676ee58c1b79ab2f5a383818d0ebc")
	if err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", r)
}
GetModuleSource
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.GetModuleSource(ctx,
		"63ced0f4b0ad467f3abee79f8e8c8c891c0676ee58c1b79ab2f5a383818d0ebc",
		"935d17711a4dea10ba5a851df4f19cfdd7cdbd79c8d6ec9abfe5cacff873f6d0",
	)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", r)
}
GetIdentityProviders
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.GetIdentityProviders(ctx, "63ced0f4b0ad467f3abee79f8e8c8c891c0676ee58c1b79ab2f5a383818d0ebc")
	if err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", r)
}
GetAnonymityRevokers
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.GetAnonymityRevokers(ctx, "63ced0f4b0ad467f3abee79f8e8c8c891c0676ee58c1b79ab2f5a383818d0ebc")
	if err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", r)
}
GetCryptographicParameters
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.GetCryptographicParameters(ctx, "63ced0f4b0ad467f3abee79f8e8c8c891c0676ee58c1b79ab2f5a383818d0ebc")
	if err != nil {
		panic(err)
	}
	fmt.Printf("%s\n", r)
}
GetBannedPeers
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.GetBannedPeers(ctx)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", r)
}
Shutdown
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.Shutdown(ctx)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%t\n", r)
}
DumpStart
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.DumpStart(ctx, "path/to/file", true)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%t\n", r)
}
DumpStop
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.DumpStop(ctx)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%t\n", r)
}
GetTransactionStatus
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.GetTransactionStatus(ctx, "8af811b649875f09d6f5b7ebfcc1899cf0e58466f33f07f74daf073dc7aea17f")
	if err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", r)
}
GetTransactionStatusInBlock
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.GetTransactionStatusInBlock(ctx,
		"8af811b649875f09d6f5b7ebfcc1899cf0e58466f33f07f74daf073dc7aea17f",
		"63ced0f4b0ad467f3abee79f8e8c8c891c0676ee58c1b79ab2f5a383818d0ebc",
	)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", r)
}
GetAccountNonFinalizedTransactions
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.GetAccountNonFinalizedTransactions(ctx, "3TdFQK6hqoqoW38JQJGZ2y3RZfgVPzwB7dMKXbBdeYvdwPeF63")
	if err != nil {
		panic(err)
	}
	fmt.Printf("%s\n", r)
}
GetBlockSummary
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.GetBlockSummary(ctx, "63ced0f4b0ad467f3abee79f8e8c8c891c0676ee58c1b79ab2f5a383818d0ebc")
	if err != nil {
		panic(err)
	}
	fmt.Printf("%s\n", r)
}
GetNextAccountNonce
package main

import (
	"context"
	"fmt"
	
	"github.com/Concordium/concordium-go-sdk"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	r, err := cli.GetNextAccountNonce(ctx, "3TdFQK6hqoqoW38JQJGZ2y3RZfgVPzwB7dMKXbBdeYvdwPeF63")
	if err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", r)
}

Account Transaction Client usage

package main

import (
	"context"
	"github.com/Concordium/concordium-go-sdk"
	"github.com/Concordium/concordium-go-sdk/transaction/account"
)

func main() {
	ctx := context.Background()

	cli, err := concordium.NewClient(ctx, "host", "token")
	if err != nil {
		panic(err)
	}

	acc := account.NewClient(cli)

	err = acc.SimpleTransfer(
		&account.Context{
			Context: ctx,
			Credentials: concordium.Credentials{}, // add your credentials
			Sender: "source-address",
		},
		"destination-address",
		concordium.NewAmountFromCCD(10),
	)
	if err != nil {
		panic(err)
	}
}

Documentation

Index

Constants

View Source
const (
	NodeInfoNotInCommittee               = 0
	NodeInfoAddedButNotActiveInCommittee = 1
	NodeInfoAddedButWrongKeys            = 2
	NodeInfoActiveInCommittee            = 3
)
View Source
const (
	DefaultExpiry = 10 * time.Minute

	TransactionStatusFinalized TransactionStatus = "finalized"
	TransactionStatusCommitted TransactionStatus = "committed"
	TransactionStatusReceived  TransactionStatus = "received"

	TransactionResultSuccess TransactionResultOutcome = "success"
	TransactionResultReject  TransactionResultOutcome = "reject"
)
View Source
const (
	BlockItemVersion0 BlockItemVersion = 0

	BlockItemKindAccountTransaction   BlockItemKind = 0
	BlockItemKindCredentialDeployment BlockItemKind = 1
	BlockItemKindUpdateInstruction    BlockItemKind = 2
)
View Source
const DefaultNetworkId = 100

Variables

This section is empty.

Functions

func DeserializeModel

func DeserializeModel(b []byte, v any) error

func SerializeModel

func SerializeModel(v any) ([]byte, error)

Types

type AccountAddress

type AccountAddress string

AccountAddress base-58 check with version byte 1 encoded address (with Bitcoin mapping table)

func (*AccountAddress) Deserialize

func (a *AccountAddress) Deserialize(b []byte) error

func (*AccountAddress) DeserializeModel

func (a *AccountAddress) DeserializeModel(b []byte) (int, error)

func (*AccountAddress) Serialize

func (a *AccountAddress) Serialize() ([]byte, error)

func (*AccountAddress) SerializeModel

func (a *AccountAddress) SerializeModel() ([]byte, error)

type AccountEncryptedAmount

type AccountEncryptedAmount struct {
	IncomingAmounts []EncryptedAmount `json:"incomingAmounts"`
	SelfAmount      EncryptedAmount   `json:"selfAmount"`
	StartIndex      int               `json:"startIndex"`
}

type AccountInfo

type AccountInfo struct {
	AccountNonce           uint64                  `json:"accountNonce"`
	AccountAmount          *Amount                 `json:"accountAmount"`
	AccountReleaseSchedule *AccountReleaseSchedule `json:"accountReleaseSchedule"`
	AccountCredentials     any                     `json:"accountCredentials"` // TODO
	AccountThreshold       int                     `json:"accountThreshold"`
	AccountEncryptedAmount *AccountEncryptedAmount `json:"accountEncryptedAmount"`
	AccountEncryptionKey   EncryptionKey           `json:"accountEncryptionKey"`
	AccountIndex           uint64                  `json:"accountIndex"`
	AccountAddress         AccountAddress          `json:"accountAddress"`
}

AccountInfo Messy documentations: https://github.com/Concordium/concordium-node/blob/main/docs/grpc-for-smart-contracts.md#getaccountinfo https://github.com/Concordium/concordium-node/blob/main/docs/grpc.md#getaccountinfo--blockhash---accountaddress---accountinfo

type AccountNonce

type AccountNonce uint64

type AccountReleaseSchedule

type AccountReleaseSchedule struct {
	Schedule []*Release `json:"schedule"`
	Total    *Amount    `json:"total"`
}

type Address

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

func WrapAccountAddress

func WrapAccountAddress(addr AccountAddress) *Address

func WrapContractAddress

func WrapContractAddress(addr *ContractAddress) *Address

func (*Address) DeserializeModel

func (a *Address) DeserializeModel(b []byte) (int, error)

func (*Address) MarshalJSON

func (a *Address) MarshalJSON() ([]byte, error)

func (*Address) SerializeModel

func (a *Address) SerializeModel() ([]byte, error)

func (*Address) UnmarshalJSON

func (a *Address) UnmarshalJSON(b []byte) error

type Amount

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

func NewAmountFromCCD

func NewAmountFromCCD(v float64) *Amount

func NewAmountFromMicroCCD

func NewAmountFromMicroCCD(v int) *Amount

func NewAmountZero

func NewAmountZero() *Amount

func (*Amount) CCD

func (a *Amount) CCD() float64

func (*Amount) Deserialize

func (a *Amount) Deserialize(b []byte) error

func (*Amount) DeserializeModel

func (a *Amount) DeserializeModel(b []byte) (int, error)

func (*Amount) MarshalJSON

func (a *Amount) MarshalJSON() ([]byte, error)

func (*Amount) MicroCCD

func (a *Amount) MicroCCD() int

func (*Amount) Serialize

func (a *Amount) Serialize() ([]byte, error)

func (*Amount) SerializeModel

func (a *Amount) SerializeModel() ([]byte, error)

func (*Amount) UnmarshalJSON

func (a *Amount) UnmarshalJSON(b []byte) error

type AnonymityRevoker

type AnonymityRevoker struct {
	ArIdentity    int                          `json:"arIdentity"`
	ArDescription *AnonymityRevokerDescription `json:"arDescription"`
	ArPublicKey   string                       `json:"arPublicKey"`
}

type AnonymityRevokerDescription

type AnonymityRevokerDescription struct {
	Name        string `json:"name"`
	Url         string `json:"url"`
	Description string `json:"description"`
}

type BakerId

type BakerId uint64

type BakerInfo

type BakerInfo struct {
	BakerId           BakerId        `json:"bakerId"`
	BakerAccount      AccountAddress `json:"bakerAccount"`
	BakerLotteryPower float64        `json:"bakerLotteryPower"`
}

type BirkParameters

type BirkParameters struct {
	ElectionDifficulty float64      `json:"electionDifficulty"`
	ElectionNonce      string       `json:"electionNonce"`
	Bakers             []*BakerInfo `json:"bakers"`
}

type BlockHash

type BlockHash string

BlockHash base-16 encoded hash of a block (64 characters)

type BlockHeight

type BlockHeight uint64

type BlockInfo

type BlockInfo struct {
	BlockHash             BlockHash   `json:"blockHash"`
	BlockParent           BlockHash   `json:"blockParent"`
	BlockLastFinalized    BlockHash   `json:"blockLastFinalized"`
	BlockHeight           BlockHeight `json:"blockHeight"`
	EraBlockHeight        BlockHeight `json:"eraBlockHeight"`
	GenesisIndex          int         `json:"genesisIndex"`
	BlockReceiveTime      time.Time   `json:"blockReceiveTime"`
	BlockArriveTime       time.Time   `json:"blockArriveTime"`
	BlockSlot             int         `json:"blockSlot"`
	BlockSlotTime         time.Time   `json:"blockSlotTime"`
	BlockBaker            BakerId     `json:"blockBaker"`
	Finalized             bool        `json:"finalized"`
	TransactionCount      int         `json:"transactionCount"`
	TransactionEnergyCost int         `json:"transactionEnergyCost"`
	// undocumented but returned in fact
	TransactionsSize int       `json:"transactionsSize"`
	BlockStateHash   BlockHash `json:"blockStateHash"`
}

type BlockItemKind

type BlockItemKind uint8

type BlockItemVersion

type BlockItemVersion uint8

type Branch

type Branch struct {
	BlockHash BlockHash `json:"blockHash"`
	Children  []*Branch `json:"children"`
}

type Client

type Client interface {
	// PeerConnect Suggest to w peer to connect to the submitted peer details.
	// This, if successful, adds the peer to the list of given addresses.
	PeerConnect(ctx context.Context, ip string, port int) (bool, error)

	// PeerDisconnect Disconnect from the peer and remove them from the given addresses list
	// if they are on it. Return if the request was processed successfully.
	PeerDisconnect(ctx context.Context, ip string, port int) (bool, error)

	// PeerUptime Peer uptime
	PeerUptime(ctx context.Context) (int64, error)

	// PeerTotalSent Peer total number of sent packets
	PeerTotalSent(ctx context.Context) (int, error)

	// PeerTotalReceived Peer total number of received packets
	PeerTotalReceived(ctx context.Context) (int, error)

	// PeerVersion Peer client software version
	PeerVersion(ctx context.Context) (string, error)

	// PeerStats Stats for connected peers
	PeerStats(ctx context.Context, includeBootstrappers bool) (*PeerStats, error)

	// PeerList List of connected peers
	PeerList(ctx context.Context, includeBootstrappers bool) (*PeerList, error)

	// BanNode ...
	BanNode(ctx context.Context, element *PeerElement) (bool, error)

	// UnbanNode ...
	UnbanNode(ctx context.Context, element *PeerElement) (bool, error)

	// JoinNetwork ...
	JoinNetwork(ctx context.Context, id NetworkId) (bool, error)

	// LeaveNetwork ...
	LeaveNetwork(ctx context.Context, id NetworkId) (bool, error)

	// NodeInfo Get information about the running Node
	NodeInfo(ctx context.Context) (*NodeInfo, error)

	// GetConsensusStatus see https://github.com/Concordium/concordium-node/blob/main/docs/grpc.md#getconsensusstatus--consensusstatus
	GetConsensusStatus(ctx context.Context) (*ConsensusStatus, error)

	// GetBlockInfo see https://github.com/Concordium/concordium-node/blob/main/docs/grpc.md#getblockinfo--blockhash---blockinfo
	GetBlockInfo(ctx context.Context, hash BlockHash) (*BlockInfo, error)

	// GetAncestors see https://github.com/Concordium/concordium-node/blob/main/docs/grpc.md#getancestors--blockhash---blockhash
	GetAncestors(ctx context.Context, hash BlockHash, amount int) ([]BlockHash, error)

	// GetBranches see https://github.com/Concordium/concordium-node/blob/main/docs/grpc.md#getbranches--branch
	GetBranches(ctx context.Context) (*Branch, error)

	// GetBlocksAtHeight Get the blocks at the given height
	GetBlocksAtHeight(ctx context.Context, height BlockHeight) ([]BlockHash, error)

	// SendTransactionAsync Submit a local transaction
	SendTransactionAsync(ctx context.Context, id NetworkId, request TransactionRequest) (TransactionHash, error)

	SendTransactionAwait(ctx context.Context, id NetworkId, request TransactionRequest) (*TransactionOutcome, error)

	// StartBaker Start the baker in the consensus module
	StartBaker(ctx context.Context) (bool, error)

	// StopBaker Stop the baker in the consensus module
	StopBaker(ctx context.Context) (bool, error)

	// GetAccountList see https://github.com/Concordium/concordium-node/blob/main/docs/grpc.md#getaccountlist--blockhash---accountaddress
	GetAccountList(ctx context.Context, hash BlockHash) ([]AccountAddress, error)

	// GetInstances see https://github.com/Concordium/concordium-node/blob/main/docs/grpc.md#getinstances--blockhash---contractaddress
	GetInstances(ctx context.Context, hash BlockHash) ([]*ContractAddress, error)

	// GetAccountInfo see https://github.com/Concordium/concordium-node/blob/main/docs/grpc.md#getaccountinfo--blockhash---accountaddress---accountinfo
	GetAccountInfo(ctx context.Context, hash BlockHash, address AccountAddress) (*AccountInfo, error)

	// GetInstanceInfo see https://github.com/Concordium/concordium-node/blob/main/docs/grpc.md#getinstanceinfo--blockhash---contractaddress---contractinfo
	GetInstanceInfo(ctx context.Context, hash BlockHash, address *ContractAddress) (*InstanceInfo, error)

	// InvokeContract see https://github.com/Concordium/concordium-node/blob/main/docs/grpc.md#invokecontract--blockhash---contractcontext---invokecontractresult
	InvokeContract(ctx context.Context, hash BlockHash, context *ContractContext) (*InvokeContractResult, error)

	// GetRewardStatus see https://github.com/Concordium/concordium-node/blob/main/docs/grpc.md#getrewardstatus-blockhash---rewardstatus
	GetRewardStatus(ctx context.Context, hash BlockHash) (*RewardStatus, error)

	// GetBirkParameters see https://github.com/Concordium/concordium-node/blob/main/docs/grpc.md#getbirkparameters--blockhash---birkparameters
	GetBirkParameters(ctx context.Context, hash BlockHash) (*BirkParameters, error)

	// GetModuleList see https://github.com/Concordium/concordium-node/blob/main/docs/grpc.md#getmodulelist--blockhash---moduleref
	GetModuleList(ctx context.Context, hash BlockHash) ([]ModuleRef, error)

	// GetModuleSource see https://github.com/Concordium/concordium-node/blob/main/docs/grpc.md#getmodulesource--blockhash---moduleref---modulesource
	GetModuleSource(ctx context.Context, hash BlockHash, ref ModuleRef) (io.Reader, error)

	// GetIdentityProviders ...
	GetIdentityProviders(ctx context.Context, hash BlockHash) ([]*IdentityProvider, error)

	// GetAnonymityRevokers ...
	GetAnonymityRevokers(ctx context.Context, hash BlockHash) ([]*AnonymityRevoker, error)

	// GetCryptographicParameters ...
	GetCryptographicParameters(ctx context.Context, hash BlockHash) ([]byte, error) // TODO

	// GetBannedPeers ...
	GetBannedPeers(ctx context.Context) (*PeerList, error)

	// Shutdown ...
	Shutdown(ctx context.Context) (bool, error)

	// DumpStart ...
	DumpStart(ctx context.Context, file string, raw bool) (bool, error)

	// DumpStop ...
	DumpStop(ctx context.Context) (bool, error)

	// GetTransactionStatus Query for the status of a transaction by its hash
	GetTransactionStatus(ctx context.Context, hash TransactionHash) (*TransactionSummary, error)

	// GetTransactionStatusInBlock Query for transactions in a block by its hash
	GetTransactionStatusInBlock(ctx context.Context, hash TransactionHash, blockHash BlockHash) (*TransactionSummary, error)

	// GetAccountNonFinalizedTransactions Query for non-finalized
	// transactions present on an account by the account address
	GetAccountNonFinalizedTransactions(ctx context.Context, address AccountAddress) ([]byte, error) // TODO

	// GetBlockSummary Request a summary for a block by its hash
	GetBlockSummary(ctx context.Context, hash BlockHash) ([]byte, error) // TODO

	// GetNextAccountNonce Request next nonce information for an account
	GetNextAccountNonce(ctx context.Context, address AccountAddress) (*NextAccountNonce, error)
}

func NewClient

func NewClient(ctx context.Context, target, token string) (Client, error)

type ConsensusStatus

type ConsensusStatus struct {
	BestBlock                BlockHash   `json:"bestBlock"`
	GenesisBlock             BlockHash   `json:"genesisBlock"`
	GenesisTime              time.Time   `json:"genesisTime"`
	SlotDuration             int64       `json:"slotDuration"`
	EpochDuration            int64       `json:"epochDuration"`
	LastFinalizedBlock       BlockHash   `json:"lastFinalizedBlock"`
	BestBlockHeight          BlockHeight `json:"bestBlockHeight"`
	LastFinalizedBlockHeight BlockHeight `json:"lastFinalizedBlockHeight"`
	BlocksReceivedCount      int         `json:"blocksReceivedCount"`
	BlockLastReceivedTime    time.Time   `json:"blockLastReceivedTime"`
	BlockReceiveLatencyEMA   float64     `json:"blockReceiveLatencyEMA"`
	BlockReceiveLatencyEMSD  float64     `json:"blockReceiveLatencyEMSD"`
	BlockReceivePeriodEMA    float64     `json:"blockReceivePeriodEMA"`
	BlockReceivePeriodEMSD   float64     `json:"blockReceivePeriodEMSD"`
	BlocksVerifiedCount      int         `json:"blocksVerifiedCount"`
	BlockLastArrivedTime     time.Time   `json:"blockLastArrivedTime"`
	BlockArriveLatencyEMA    float64     `json:"blockArriveLatencyEMA"`
	BlockArriveLatencyEMSD   float64     `json:"blockArriveLatencyEMSD"`
	BlockArrivePeriodEMA     float64     `json:"blockArrivePeriodEMA"`
	BlockArrivePeriodEMSD    float64     `json:"blockArrivePeriodEMSD"`
	TransactionsPerBlockEMA  float64     `json:"transactionsPerBlockEMA"`
	TransactionsPerBlockEMSD float64     `json:"transactionsPerBlockEMSD"`
	FinalizationCount        int         `json:"finalizationCount"`
	LastFinalizedTime        time.Time   `json:"lastFinalizedTime"`
	FinalizationPeriodEMA    float64     `json:"finalizationPeriodEMA"`
	FinalizationPeriodEMSD   float64     `json:"finalizationPeriodEMSD"`
	ProtocolVersion          int         `json:"protocolVersion"`
	GenesisIndex             int         `json:"genesisIndex"`
	CurrentEraGenesisBlock   BlockHash   `json:"currentEraGenesisBlock"`
	CurrentEraGenesisTime    time.Time   `json:"currentEraGenesisTime"`
}

type ConsensusType

type ConsensusType string

type ContractAddress

type ContractAddress struct {
	Index    uint64 `json:"index"`
	SubIndex uint64 `json:"subindex"`
}

ContractAddress is a JSON record with two fields {index : Int, subindex : Int}

func (*ContractAddress) Deserialize

func (a *ContractAddress) Deserialize(b []byte) error

func (*ContractAddress) DeserializeModel

func (a *ContractAddress) DeserializeModel(b []byte) (int, error)

func (*ContractAddress) Serialize

func (a *ContractAddress) Serialize() ([]byte, error)

Serialize returns bytes (Index and SubIndex in big-endian order) of serialized ContractAddress.

func (*ContractAddress) SerializeModel

func (a *ContractAddress) SerializeModel() ([]byte, error)

type ContractContext

type ContractContext struct {
	Invoker   *Address         `json:"invoker"`
	Contract  *ContractAddress `json:"contract"`
	Amount    *Amount          `json:"amount"`
	Method    ReceiveName      `json:"method"`
	Parameter Model            `json:"parameter"`
	Energy    int              `json:"energy"`
}

type ContractName

type ContractName string

func (*ContractName) DeserializeModel

func (n *ContractName) DeserializeModel([]byte) (int, error)

func (*ContractName) SerializeModel

func (n *ContractName) SerializeModel() ([]byte, error)

type Credentials

type Credentials map[uint8]map[uint8]KeyPair

type DecryptedSignKey

type DecryptedSignKey string

func (DecryptedSignKey) Decode

func (k DecryptedSignKey) Decode() ([]byte, error)

type Deserializer

type Deserializer interface {
	Deserialize(b []byte) error
}

type EncryptedAmount

type EncryptedAmount string

EncryptedAmount base-16 encoded string (384 characters)

type EncryptedSignKey

type EncryptedSignKey struct {
	Password   string                   `json:"password"`
	Metadata   EncryptedSignKeyMetadata `json:"metadata"`
	CipherText string                   `json:"cipherText"`
}

func (*EncryptedSignKey) Decode

func (k *EncryptedSignKey) Decode() ([]byte, error)

type EncryptedSignKeyMetadata

type EncryptedSignKeyMetadata struct {
	Iterations           int    `json:"iterations"`
	Salt                 string `json:"salt"`
	InitializationVector string `json:"initializationVector"`
}

type EncryptionKey

type EncryptionKey string

EncryptionKey base-16 encoded string (192 characters)

type IdentityProvider

type IdentityProvider struct {
	IpIdentity     int                          `json:"ipIdentity"`
	IpDescription  *IdentityProviderDescription `json:"ipDescription"`
	IpVerifyKey    string                       `json:"ipVerifyKey"`
	IpCdiVerifyKey string                       `json:"ipCdiVerifyKey"`
}

type IdentityProviderDescription

type IdentityProviderDescription struct {
	Name        string `json:"name"`
	Url         string `json:"url"`
	Description string `json:"description"`
}

type InitName

type InitName string

func NewInitName

func NewInitName(contractName ContractName) InitName

func (*InitName) DeserializeModel

func (n *InitName) DeserializeModel(b []byte) (int, error)

func (*InitName) Serialize

func (n *InitName) Serialize() ([]byte, error)

func (*InitName) SerializeModel

func (n *InitName) SerializeModel() ([]byte, error)

type InstanceInfo

type InstanceInfo struct {
	Amount       *Amount        `json:"amount"`
	SourceModule ModuleRef      `json:"sourceModule"`
	Owner        AccountAddress `json:"owner"`
	Name         InitName       `json:"name"`
	Model        Model          `json:"model"`
	Methods      []ReceiveName  `json:"methods"`
}

type InvokeContractResult

type InvokeContractResult struct {
	Tag         InvokeContractResultTag `json:"tag"`
	UsedEnergy  int                     `json:"usedEnergy"`
	ReturnValue Model                   `json:"returnValue"`
	Events      any                     `json:"events"` // TODO
	Reason      any                     `json:"reason"` // TODO
}

type InvokeContractResultTag

type InvokeContractResultTag string
const (
	InvokeContractResultSuccess InvokeContractResultTag = "success"
	InvokeContractResultFailure InvokeContractResultTag = "failure"
)

type KeyPair

type KeyPair struct {
	SignKey   SignKey
	VerifyKey string
}

type Model

type Model string

func (*Model) Deserialize

func (m *Model) Deserialize(v any) error

func (*Model) Serialize

func (m *Model) Serialize(v any) error

type ModelDeserializer

type ModelDeserializer interface {
	DeserializeModel(b []byte) (int, error)
}

type ModelSerializer

type ModelSerializer interface {
	SerializeModel() ([]byte, error)
}

type ModuleRef

type ModuleRef string

ModuleRef base-16 encoded module reference (64 characters)

func (*ModuleRef) Deserialize

func (m *ModuleRef) Deserialize(b []byte) error

func (*ModuleRef) Serialize

func (m *ModuleRef) Serialize() ([]byte, error)

type NetworkId

type NetworkId uint32

type NextAccountNonce

type NextAccountNonce struct {
	AllFinal bool         `json:"allFinal"`
	Nonce    AccountNonce `json:"nonce"`
}

type NodeId

type NodeId string

type NodeInfo

type NodeInfo struct {
	NodeId                      NodeId
	CurrentLocaltime            int64
	PeerType                    PeerType
	ConsensusBakerRunning       bool
	ConsensusRunning            bool
	ConsensusType               ConsensusType
	ConsensusBakerCommittee     NodeInfoIsInBakingCommittee
	ConsensusFinalizerCommittee bool
	ConsensusBakerId            BakerId
}

type NodeInfoIsInBakingCommittee

type NodeInfoIsInBakingCommittee int

type PeerElement

type PeerElement struct {
	NodeId        NodeId
	Ip            string
	Port          int
	CatchupStatus PeerElementCatchupStatus
}

type PeerElementCatchupStatus

type PeerElementCatchupStatus int
const (
	PeerElementUpToDate   PeerElementCatchupStatus = 0
	PeerElementPending    PeerElementCatchupStatus = 1
	PeerElementCatchingUp PeerElementCatchupStatus = 2
)

type PeerList

type PeerList struct {
	Type  PeerType
	Peers []*PeerElement
}

type PeerStats

type PeerStats struct {
	Peers     []*PeerStatsElement
	AvgBpsIn  int
	AvgBpsOut int
}

type PeerStatsElement

type PeerStatsElement struct {
	NodeId          NodeId
	PacketsSent     int
	PacketsReceived int
	Latency         int
}

type PeerType

type PeerType string

type ReceiveName

type ReceiveName string

func NewReceiveName

func NewReceiveName(contractName ContractName, receiver string) ReceiveName

func (*ReceiveName) DeserializeModel

func (n *ReceiveName) DeserializeModel(b []byte) (int, error)

func (*ReceiveName) Serialize

func (n *ReceiveName) Serialize() ([]byte, error)

func (*ReceiveName) SerializeModel

func (n *ReceiveName) SerializeModel() ([]byte, error)

type Release

type Release struct {
	Timestamp    time.Time         `json:"timestamp"`
	Amount       *Amount           `json:"amount"`
	Transactions []TransactionHash `json:"transactions"`
}

type RewardStatus

type RewardStatus struct {
	TotalAmount               *Amount `json:"totalAmount"`
	TotalEncryptedAmount      *Amount `json:"totalEncryptedAmount"`
	GasAccount                *Amount `json:"gasAccount"`
	BakingRewardAccount       *Amount `json:"bakingRewardAccount"`
	FinalizationRewardAccount *Amount `json:"finalizationRewardAccount"`
}

type Serializer

type Serializer interface {
	Serialize() ([]byte, error)
}

type SignKey

type SignKey interface {
	Decode() ([]byte, error)
}

type TransactionEvent

type TransactionEvent struct {
	Address  ContractAddress `json:"address"`
	Contents string          `json:"contents"`
}

type TransactionHash

type TransactionHash string

TransactionHash base-16 encoded hash of a transaction (64 characters)

type TransactionOutcome

type TransactionOutcome struct {
	Hash   TransactionHash   `json:"hash"`
	Result TransactionResult `json:"result"`
}

func (*TransactionOutcome) Error

func (o *TransactionOutcome) Error() error

type TransactionRequest

type TransactionRequest interface {
	Serializer
	Version() BlockItemVersion
	Kind() BlockItemKind
	ExpiredAt() time.Time
}

type TransactionResult

type TransactionResult struct {
	Outcome TransactionResultOutcome `json:"outcome"`
	Events  TransactionResultEvents  `json:"events,omitempty"`
}

type TransactionResultEvents

type TransactionResultEvents []*TransactionEvent

type TransactionResultOutcome

type TransactionResultOutcome string

type TransactionStatus

type TransactionStatus string

type TransactionSummary

type TransactionSummary struct {
	Status   TransactionStatus             `json:"status"`
	Outcomes map[string]TransactionOutcome `json:"outcomes"`
}

Directories

Path Synopsis
transaction

Jump to

Keyboard shortcuts

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