templates

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContractTemplate

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

ContractTemplate template representation

func (ContractTemplate) GetAddress

func (contract ContractTemplate) GetAddress() string

GetAddress returns the contract address

func (ContractTemplate) GetProgram

func (contract ContractTemplate) GetProgram() []byte

GetProgram returns the program bytes

type HTLC

type HTLC struct {
	ContractTemplate
}

HTLC template representation

func MakeHTLC

func MakeHTLC(owner, receiver, hashFunction, hashImage string, expiryRound, maxFee uint64) (HTLC, error)

MakeHTLC allows a user to recieve the Algo prior to a deadline (in terms of a round) by proving a knowledge of a special value or to forfeit the ability to claim, returning it to the payer. This contract is usually used to perform cross-chained atomic swaps

More formally - Algos can be transferred under only two circumstances: 1. To receiver if hash_function(arg_0) = hash_value 2. To owner if txn.FirstValid > expiry_round ...

Parameters ---------- - owner : string an address that can receive the asset after the expiry round - receiver: string address to receive Algos - hashFunction : string the hash function to be used (must be either sha256 or keccak256) - hashImage : string the hash image in base64 - expiryRound : uint64 the round on which the assets can be transferred back to owner - maxFee : uint64 the maximum fee that can be paid to the network by the account

type Split

type Split struct {
	ContractTemplate
	// contains filtered or unexported fields
}

Split template representation

func MakeSplit

func MakeSplit(owner, receiverOne, receiverTwo string, ratn, ratd, expiryRound, minPay, maxFee uint64) (Split, error)

MakeSplit splits money sent to some account to two recipients at some ratio. This is a contract account.

This allows either a two-transaction group, for executing a split, or single transaction, for closing the account.

Withdrawals from this account are allowed as a group transaction which sends receiverOne and receiverTwo amounts with exactly the ratio of ratn/ratd. At least minPay must be sent to receiverOne. (CloseRemainderTo must be zero.)

After expiryRound passes, all funds can be refunded to owner.

Parameters:

  • owner: the address to refund funds to on timeout
  • receiverOne: the first recipient in the split account
  • receiverTwo: the second recipient in the split account
  • ratn: fraction of money to be paid to the first recipient (numerator)
  • ratd: fraction of money to be paid to the first recipient (denominator)
  • expiryRound: the round at which the account expires
  • minPay: minimum amount to be paid out of the account
  • maxFee: half of the maximum fee used by each split forwarding group transaction

func (Split) GetSendFundsTransaction

func (contract Split) GetSendFundsTransaction(amount uint64, precise bool, firstRound, lastRound, fee uint64, genesisHash []byte) ([]byte, error)

GetSendFundsTransaction returns a group transaction array which transfer funds according to the contract's ratio the returned byte array is suitable for passing to SendRawTransaction amount: uint64 number of assets to be transferred total precise: handles rounding error. When False, the amount will be divided as closely as possible but one account will get

slightly more. When true, returns an error.

Jump to

Keyboard shortcuts

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