contract

package
v0.0.30 Latest Latest
Warning

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

Go to latest
Published: May 26, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateCompliance

func CreateCompliance(config [][]ComplianceConfig) ([]*pb.TokenCompliance, error)

func CreateContractFee

func CreateContractFee(config ContractFeeConfig, parts *big.Int) (*pb.ContractFees, error)

func CreateContractTXN added in v0.0.24

func CreateContractTXN(nonceInfo nonce.NonceInfo, data *TokenData, publicKeyBase58 string, privateKeyBase58 string, feeID string, feeAmountParts string) (*pb.InstrumentContract, error)

func CreateCustomParameters

func CreateCustomParameters(params []KeyValuePair) []*pb.KeyValuePair

func CreateDenomination

func CreateDenomination(parts *big.Int, partName string) (*pb.CoinDenomination, error)

func CreateExpenseRatio

func CreateExpenseRatio(config []ExpenseRatioConfig) ([]*pb.ExpenseRatio, error)

func CreateGovernance

func CreateGovernance(govType GovernanceTypeHelper, regularQuorum float64, fastQuorum *float64, allowedProposalContracts []string, allowedVotingContracts []string, votingThreshold float64, alwaysWinner *bool, allowMultiChoice bool) (*pb.Governance, error)

func CreateMaxSupply

func CreateMaxSupply(maxSupply float64, parts *big.Int) (string, error)

func CreateMaxSupplyRelease

func CreateMaxSupplyRelease(releaseConfig []ReleaseScheduleConfig, parts *big.Int, maxSupply string) ([]*pb.MaxSupplyRelease, error)

func CreatePremint

func CreatePremint(premints []PremintConfig, parts *big.Int) ([]*pb.PreMintWallet, error)

func CreateRestrictedKeys

func CreateRestrictedKeys(config []RestrictedConfig) ([]*pb.RestrictedKey, error)

func SendInstrumentContract

func SendInstrumentContract(grpcAddr string, txn *pb.InstrumentContract) (*emptypb.Empty, error)

SendInstrumentContract submits an instrument contract to the network via gRPC

func SendUpdate added in v0.0.19

func SendUpdate(grpcAddr string, txn *pb.ContractUpdateTXN) (*emptypb.Empty, error)

SendUpdate submits an instrument contract to the network via gRPC

func UpdateContractTXN added in v0.0.19

func UpdateContractTXN(nonceInfo nonce.NonceInfo, data *UpdateData, publicKeyBase58 string, privateKeyBase58 string, feeID string, feeAmountParts string) (*pb.ContractUpdateTXN, error)

Types

type ComplianceConfig

type ComplianceConfig struct {
	ContractID string // what contract is the compliance certificate issued from?
	Level      uint32 // what rating is it
}

type ContractFeeConfig

type ContractFeeConfig struct {
	Type                 FeeType  // the type of fee
	Address              string   // where the fees go to
	Fee                  float64  // depends on type: fixed (number of tokens) | current equivalent $xx.xx | percent (0-100) || remainder not given to burn and validator goes here
	Burn                 float64  // Percentage burned (0-100)
	Validator            float64  // Percentage to validator (0-100)
	AllowedFeeInstrument []string // contractID of the contracts allowed to pay the fee instrument. //! If allowed fee instrument is not self, a calculation is done based on self/auth currency equivalent values
}

type ExpenseRatioConfig

type ExpenseRatioConfig struct {
	Month   uint32  // month number (1 January - 12 December)
	Day     uint32  // day of month
	Percent float64 // 0 - 100
}

type FeeType

type FeeType int16
const (
	FeeFixed              FeeType = 0 // an amount of parts to be paid
	FeeCurrencyEquivalent FeeType = 1 // rate based on self/ace oracles
	FeePercentage         FeeType = 2 // percentage of transaction amount
)

type GovernanceType

type GovernanceType int16
const (
	Staged    GovernanceType = 0
	Cycle     GovernanceType = 1
	Staggared GovernanceType = 2
	Adaptive  GovernanceType = 3

	None GovernanceType = 32767
)

type GovernanceTypeHelper

type GovernanceTypeHelper struct {
	Type           GovernanceType
	ProposalPeriod *ProposalPeriod
	Stages         []*Stage
	StartTimestamp *timestamppb.Timestamp // only present for staggared, staged, and cycle. For staged and cycle, the time is truncated to hour (ie if time is 11:35.32, network will use 11:00:00)
}

type KeyValuePair

type KeyValuePair struct {
	Key   string
	Value string
}

type PremintConfig

type PremintConfig struct {
	Address string  // the address to premint in base58
	Amount  float64 // the amount as a whole number (parts calculation done within helper function)
}

type ProposalPeriod

type ProposalPeriod struct {
	PeriodType   ProposalPeriodType // days or months
	VotingPeriod uint32             // how long is it voted on
}

Present with staged, cycle, and staggered types -- not adaptive If using in staged and want a stage to be a month, you MUST put months for proposal period. Ie you can't have 60 days as the period and a 1 month stage.

type ProposalPeriodType

type ProposalPeriodType int16
const (
	Days   ProposalPeriodType = 0
	Months ProposalPeriodType = 1
)

type ReleaseScheduleConfig

type ReleaseScheduleConfig struct {
	ReleaseDate *timestamppb.Timestamp // the date of the release (in UTC)
	Amount      float64                // the amount to release
}

type RestrictedConfig

type RestrictedConfig struct {
	PublicKey      helper.PublicKey // the public key to restrict (if not specified, the contract public key is used). Special r_ keys can be restricted, normal keys can not
	TimeDelay      int64            // can only be put on wallets that don't already exist // TODO verify
	Global         bool             // applies restrictions to wallet accross all contracts //! can only be put on wallets that don't already exist
	UpdateContract bool             // wallets that can upgrade the contract (key weight may create some restrictions regarding other keys)
	Transfer       bool             // is this key allowed to transfer tokens in this token
	Quash          bool             // is this key an authorized key a quash quorum to stop a time delayed transaction
	Mint           bool             // is this key allowed to mint new tokens
	Propose        bool             // is this key allowed to propose new governance proposals within this token
	Vote           bool             // is this key allowed to vote on governance proposals within this token
	Compliance     bool             // is this key allowed to create compliance certificates relating to this token
	ExpenseRatio   bool             // is this key allowed to call in the expense ratio of this token
	CurEquiv       bool             // is this key allowed to publish a self currency equivalent for this token
	Revoke         bool             // is this key allowed to revoke (SBT only) within this token
	KeyWeight      uint32           // lower the weight the higher permissioned it is. Higher permissioned keys can not be removed by lower permissioned keys
}

If not specified default false

type Stage

type Stage struct {
	PeriodType  ProposalPeriodType // days or months
	Length      uint32             // how long does the period last
	Break       bool               // if true, no voting occurs, if false, voting occurs
	MaxApproved uint32             // max number of approved proposals that pass through this stage
}

Only present in staged governance type

type TokenData

type TokenData struct {
	Type               pb.CONTRACT_TYPE       // Type of token (token, nft, sbt)
	ContractVersion    uint64                 // [suggested] major (as needed) - minor (x2) - patch (x3) (ie 1.1.0 = 101000 = 1 | 01 | 000)
	ContractId         string                 // Contract ID (ie $ZRA+0000 - must be unique to network)
	Symbol             string                 // Symbol (ie ZRA) without any contractID identifier (ie $ZRA+0000)
	Name               string                 // Name of the contract (ie ZERA)
	Memo               *string                // Memo in base
	Governance         *pb.Governance         // Governance configuration (ie staged, cycle, adaptive, staged, cycle, [empty])
	RestrictedKeys     []*pb.RestrictedKey    // Restricted keys for the contract (ie empty (not suitable for most cases), other specicial permissions)
	Denomination       *pb.CoinDenomination   // How many 'parts' per coin there are (ie ZERA has 1_000_000_000 parts per coin)
	MaxSupply          string                 // Maximum supply of the contract in denomination units (not full coins)
	MaxSupplyRelease   []*pb.MaxSupplyRelease // An unlocking schedule
	Premint            []*pb.PreMintWallet    // Wallets to immediately premint supply to
	CustomParameters   []*pb.KeyValuePair     // Custom values contracts can put on chain (can be used for integrations / standards)
	ExpenseRatio       []*pb.ExpenseRatio     // Expense ratio configuration for contract (most contracts don't use this)
	UpdateExpenseRatio bool                   // Whether the contract can update its expense ratio later
	ContractFees       *pb.ContractFees       // Configuration to charge fees to users for *transfers* on top of base fees
	UpdateContractFees bool                   // Whether the contract can update its fees later
	QuashThreshold     *uint32                // Number of restricted wallets needed to quash a transaction (most contracts don't use this)
	TokenCompliance    []*pb.TokenCompliance  // Token compliance configuration (most contracts don't use this)
	KycStatus          bool                   // If true, this contract requires KYC (compliance status) to transact.
	ImmutableKycStatus bool                   // If true, this contract cannot change its requirement of KYC status later.
	CurEquivStart      *float64               // A starter version of "SelfCurrencyEquiv" that can set initial on chain rate, pass in as float64
}

type UpdateData added in v0.0.19

type UpdateData struct {
	ContractId         string                // Your existing contract ID
	ContractVersion    uint64                // [suggested] major (as needed) - minor (x2) - patch (x3) (ie 1.1.0 = 101000 = 1 | 01 | 000) //! version number must be greater than current version
	Name               *string               // Optionally change the name
	Memo               *string               // Memo in base
	Governance         *pb.Governance        // Governance configuration (ie staged, cycle, adaptive, staged, cycle, [empty])
	RestrictedKeys     []*pb.RestrictedKey   // Restricted keys for the contract (ie empty (not suitable for most cases), other specicial permissions)
	ContractFees       *pb.ContractFees      // Configuration to charge fees to users for *transfers* on top of base fees
	CustomParameters   []*pb.KeyValuePair    // Custom values contracts can put on chain (can be used for integrations / standards)
	ExpenseRatio       []*pb.ExpenseRatio    // Expense ratio configuration for contract (most contracts don't use this)
	TokenCompliance    []*pb.TokenCompliance // Token compliance configuration (most contracts don't use this)
	KycStatus          *bool                 // If true, this contract requires KYC (compliance status) to transact.
	ImmutableKycStatus *bool                 // If true, this contract cannot change its requirement of KYC status later.
	QuashThreshold     *uint32               // Number of restricted wallets needed to quash a transaction (most contracts don't use this)
}

Jump to

Keyboard shortcuts

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