tongo

package module
v1.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: MIT Imports: 15 Imported by: 45

README

tongo


Go implementation of libraries for TON blockchain.

Library structure

  1. ADNL - low level adnl protocol implementation
  2. Lite client - interaction with TON node as lite client
  3. BOC - cells and bag-of-cells methods and primitives
  4. TL - interaction with binary data described by TL (Type Language) schemas
  5. TLB - interaction with binary data (in Cells) described by TL-B (Typed Language - Binary) schemas
  6. TVM - interaction with TVM (TON Virtual Machine)
  7. Wallet - tools to simplify the deployment and interaction with the wallet smart contract
  8. Contract - tools to simplify the interaction with the smart contracts like Jettons and NFT
  9. Examples

Dependencies

Libraries

For TVM executor you need a libraries from lib/darwin (MAC) or lib/linux

Connection to TON node

For connect to TON node you need to know public key and ip:port. In most cases you can use public config files. Download global-config.json (mainnet) or testnet-global.config.json (testnet) file from ton.org Lite client supports auto-download mainnet config from ton.org.

Package installation

go get github.com/tonkeeper/tongo

Basic types

Tongo operates with TON blockchain structures described in block.tlb and some types described in lite_api.tl. Go definitions of this types you can find in files: account.go, transactions.go, models.go ...

Chat

You can join to our chat in telegram - https://t.me/tongo_lib

Don't be afraid if you see only russians - we welcome any english speakers too.

Documentation

Index

Constants

View Source
const OneTON tlb.Grams = 1_000_000_000

Variables

View Source
var BlockchainInterfaceIsNil = errors.New("blockchain interface is nil")

Functions

func CreateExternalMessage

func CreateExternalMessage(address AccountID, body *boc.Cell, init *tlb.StateInit, importFee tlb.Grams) (tlb.Message, error)

Types

type AccountID

type AccountID struct {
	Workchain int32
	Address   [32]byte
}

func AccountIDFromBase64Url

func AccountIDFromBase64Url(s string) (AccountID, error)

func AccountIDFromRaw

func AccountIDFromRaw(s string) (AccountID, error)

func AccountIDFromTlb added in v1.0.1

func AccountIDFromTlb(a tlb.MsgAddress) (*AccountID, error)

TODO: replace pointer with nullable type

func MustParseAccountID

func MustParseAccountID(s string) AccountID

func NewAccountId

func NewAccountId(id int32, addr [32]byte) *AccountID

func ParseAccountID

func ParseAccountID(s string) (AccountID, error)

func (AccountID) IsZero

func (id AccountID) IsZero() bool

func (AccountID) MarshalJSON

func (id AccountID) MarshalJSON() ([]byte, error)

func (AccountID) MarshalTL

func (id AccountID) MarshalTL() ([]byte, error)

func (AccountID) String

func (id AccountID) String() string

func (AccountID) ToHuman

func (id AccountID) ToHuman(bounce, testnet bool) string

func (*AccountID) ToMsgAddress added in v1.0.1

func (id *AccountID) ToMsgAddress() tlb.MsgAddress

func (AccountID) ToRaw

func (id AccountID) ToRaw() string

func (*AccountID) UnmarshalJSON

func (id *AccountID) UnmarshalJSON(data []byte) error

func (*AccountID) UnmarshalTL

func (id *AccountID) UnmarshalTL(r io.Reader) error

type AccountInfo

type AccountInfo struct {
	Status            tlb.AccountStatus
	Balance           uint64
	Data              []byte
	Code              []byte
	FrozenHash        Bits256
	LastTransactionLt uint64
}

func GetAccountInfo added in v1.0.1

func GetAccountInfo(a tlb.Account) (AccountInfo, error)

type Bits256 added in v1.0.1

type Bits256 tlb.Bits256

func MustParseHash

func MustParseHash(s string) Bits256

func ParseHash

func ParseHash(s string) (Bits256, error)

func (Bits256) Base64 added in v1.0.1

func (h Bits256) Base64() string

func (*Bits256) FromBase64 added in v1.0.1

func (h *Bits256) FromBase64(s string) error

func (*Bits256) FromBase64URL added in v1.0.1

func (h *Bits256) FromBase64URL(s string) error

func (*Bits256) FromBytes added in v1.0.1

func (h *Bits256) FromBytes(b []byte) error

func (*Bits256) FromHex added in v1.0.1

func (h *Bits256) FromHex(s string) error

func (*Bits256) FromUnknownString added in v1.0.1

func (h *Bits256) FromUnknownString(s string) error

func (Bits256) Hex added in v1.0.1

func (h Bits256) Hex() string

func (Bits256) MarshalJSON added in v1.0.1

func (b Bits256) MarshalJSON() ([]byte, error)

func (*Bits256) Scan added in v1.0.1

func (h *Bits256) Scan(src interface{}) error

Scan implements Scanner for database/sql.

func (*Bits256) UnmarshalJSON added in v1.0.1

func (b *Bits256) UnmarshalJSON(buf []byte) error

func (Bits256) Value added in v1.0.1

func (h Bits256) Value() (driver.Value, error)

Value implements valuer for database/sql.

type BlockID added in v1.0.1

type BlockID struct {
	Workchain int32
	Shard     uint64
	Seqno     uint32
}

func (BlockID) String added in v1.0.1

func (id BlockID) String() string

type BlockIDExt added in v1.0.1

type BlockIDExt struct {
	BlockID
	RootHash Bits256
	FileHash Bits256
}

func GetParents added in v1.0.1

func GetParents(i tlb.BlockInfo) ([]BlockIDExt, error)

func NewTonBlockId

func NewTonBlockId(fileHash, rootHash Bits256, seqno uint32, shard uint64, workchain int32) *BlockIDExt

func ShardIDs added in v1.0.1

func ShardIDs(blk *tlb.Block) ([]BlockIDExt, error)

ShardIDs returns a list of IDs of shard blocks this block refers to.

func ToBlockId added in v1.0.1

func ToBlockId(s tlb.ShardDesc, workchain int32) BlockIDExt

func (BlockIDExt) MarshalTL added in v1.0.1

func (id BlockIDExt) MarshalTL() ([]byte, error)

func (BlockIDExt) String added in v1.0.1

func (id BlockIDExt) String() string

func (*BlockIDExt) UnmarshalTL added in v1.0.1

func (id *BlockIDExt) UnmarshalTL(data []byte) error

type JettonMetadata

type JettonMetadata struct {
	Uri         string `json:"uri,omitempty"`
	Name        string `json:"name,omitempty"`
	Description string `json:"description,omitempty"`
	Image       string `json:"image,omitempty"`
	ImageData   []byte `json:"image_data,omitempty"`
	Symbol      string `json:"symbol,omitempty"`
	Decimals    string `json:"decimals,omitempty"`
}

type ShardID

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

func MustParseShardID

func MustParseShardID(m int64) ShardID

func ParseShardID

func ParseShardID(m int64) (ShardID, error)

func (ShardID) Encode

func (s ShardID) Encode() int64

func (ShardID) MatchAccountID

func (s ShardID) MatchAccountID(a AccountID) bool

func (ShardID) MatchBlockID

func (s ShardID) MatchBlockID(block BlockID) bool

type Transaction

type Transaction struct {
	tlb.Transaction
	BlockID BlockIDExt
}

Directories

Path Synopsis
abi
contract
dns
nft
examples
boc
tl
tlb
tvm
experiments
lib
tl
tlb

Jump to

Keyboard shortcuts

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