Giter Club home page Giter Club logo

nano-token-protocol's Introduction

package tokenchain // import "github.com/Baina-Wallet/nano-token-protocol/tokenchain"


TYPES

type Chain struct {
	// Has unexported fields.
}
    Chain represents a token chain.

func LoadChain(address, rpcURL string) (c *Chain, err error)
    LoadChain loads a chain at an address.

func NewChain(rpcURL string) (c *Chain, err error)
    NewChain initializes a new chain.

func NewChainFromSeed(seed []byte, rpcURL string) (c *Chain, err error)
    NewChainFromSeed initializes a new chain from a seed.

func (c *Chain) Address() string
    Address returns the address of the chain.

func (c *Chain) LoadState(db *sql.DB) (err error)
    LoadState loads the chain state from the DB.

func (c *Chain) Parse() (err error)
    Parse parses the chain for tokens.

func (c *Chain) SaveState(db *sql.DB) (err error)
    SaveState saves the chain state to the DB.

func (c *Chain) Swap(hash rpc.BlockHash) (s *Swap, err error)
    Swap gets the swap at the specified block hash.

func (c *Chain) Token(hash rpc.BlockHash) (t *Token, err error)
    Token gets the token at the specified block hash.

func (c *Chain) Tokens() (tokens map[string]*Token)
    Tokens gets the chain's tokens.

func (c *Chain) WaitForOpen() (err error)
    WaitForOpen waits for the open block.

type Swap struct {
	// Has unexported fields.
}
    Swap represents a token swap.

func ProposeSwap(c *Chain, a *wallet.Account, counterparty string, t *Token, amount *big.Int) (s *Swap, err error)
    ProposeSwap proposes a swap on-chain.

func (s *Swap) Accept(a *wallet.Account, t *Token, amount *big.Int) (hash rpc.BlockHash, err error)
    Accept accepts a swap proposal.

func (s *Swap) Active() bool
    Active returns whether the swap is active.

func (s *Swap) Cancel(a *wallet.Account) (hash rpc.BlockHash, err error)
    Cancel cancels a swap proposal.

func (s *Swap) Confirm(a *wallet.Account) (hash rpc.BlockHash, err error)
    Confirm confirms a swap proposal.

func (s *Swap) Hash() rpc.BlockHash
    Hash returns the block hash of the swap.

func (s *Swap) Left() (sl SwapLeg)
    Left returns the left leg of the swap.

func (s *Swap) Right() (sl SwapLeg)
    Right returns the right leg of the swap.

type SwapLeg struct {
	Account string
	Token   *Token
	Amount  *big.Int
}
    SwapLeg represents a leg of the swap.

type Token struct {
	// Has unexported fields.
}
    Token represents a token.

func TokenGenesis(c *Chain, a *wallet.Account, name string, supply *big.Int, decimals byte) (t *Token, err error)
    TokenGenesis initializes a new token on a chain.

func (t *Token) Balance(account string) (balance *big.Int)
    Balance gets the balance for account.

func (t *Token) Balances() (balances map[string]*big.Int)
    Balances gets the token balances.

func (t *Token) Decimals() byte
    Decimals returns the token decimals.

func (t *Token) Hash() rpc.BlockHash
    Hash returns the block hash of the token.

func (t *Token) Name() string
    Name returns the token name.

func (t *Token) Supply() *big.Int
    Supply returns the token supply.

func (t *Token) Transfer(a *wallet.Account, account string, amount *big.Int) (hash rpc.BlockHash, err error)
    Transfer transfers an amount of tokens to another account.

nano-token-protocol's People

Contributors

hectorchu avatar bainawallet avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.