modulepackage
1.1.0-rc1
Repository: https://github.com/fioprotocol/fio-go.git
Documentation: pkg.go.dev
# README
FIO-GO
Library for interacting with the FIO network using the go language.
Breaking Changes
In 1.0.0 and later eos-go has been imported, this is to facilitate ECC changes needed for FIO and to ensure API stability. Updating existing code using eos-go dependencies should only require:
import (
"github.com/eoscanada/eos-go"
"github.com/eoscanada/eos-go/ecc"
)
becomes:
import (
"github.com/fioprotocol/fio-go/eos"
"github.com/fioprotocol/fio-go/eos/ecc"
)
Example
This demonstrates using the library to send FIO tokens from one account to another:
package main
import (
"encoding/json"
"fmt"
"github.com/fioprotocol/fio-go"
"log"
)
func main() {
const (
url = `https://testnet.fioprotocol.io`
wif = `5JP1fUXwPxuKuNryh5BEsFhZqnh59yVtpHqHxMMTmtjcni48bqC`
to = `FIO6G9pXXM92Gy5eMwNquGULoCj3ZStwPLPdEb9mVXyEHqWN7HSuA`
)
fatal := func(e error) {
if e != nil {
log.Fatal(e)
}
}
// connect to the network, using credentials
account, api, _, err := fio.NewWifConnect(wif, url)
fatal(err)
// send ᵮ1.00
resp, err := api.SignPushActions(fio.NewTransferTokensPubKey(account.Actor, to, fio.Tokens(1.0)))
fatal(err)
// print the result
j, err := json.MarshalIndent(resp, "", " ")
fatal(err)
fmt.Println(string(j))
}
# Packages
No description provided by the author
# Functions
ActorFromPub calculates the FIO Actor (EOS Account) from a public key.
AddressHash calculates the hash used as index 5 in the fio.address fionames table from the domain name.
No description provided by the author
DecryptContent provides a new populated ObtContentResult struct given an encrypted content payload.
DomainNameHash calculates the hash used as index 4 in the fio.address domains table from the domain name.
EciesDecrypt is the inverse of EciesEncrypt, using the recipient's private key and sender's public instead.
EciesEncrypt implements the encryption format used in the content field of OBT requests.
EciesSecret derives the ecies pre-shared key from a private and public key.
GetMaxFee looks up a fee from the map, this is based on the values in the fiofees table, and does not take into account any bundled transactions for the user, use GetFee() for that.
GetMaxFeeByAction allows getting a fee given the contract action name instead of the API endpoint name.
GetMaxFees gets the current max fees as a slice of FeeValue.
GetRefBlockFor calculates the Reference for an arbitrary block and ID.
I128Hash hashes a string to an i128 database value, often used as an index for a string in a table.
MaxFeesJson provides a JSON representation of the current fee map.
MaxFeesUpdated checks if the fee map has been updated, or if using the default (possibly wrong) values.
MustNewAddNft panics on error.
No description provided by the author
MustNewRegAddress panics on a bad address, but allows embedding because it only returns one value.
No description provided by the author
MustNewRemNft creates an action or panics.
NewAccountFromWif builds an Account given a private key string.
NewAction creates an Action for FIO contract calls, assumes the permission is "active".
NewAction allows building an action and specifying the permission.
No description provided by the author
NewAddAddress adds a single public address.
NewAddAddresses adds multiple public addresses at a time.
NewAddBundles is used to purchase new bundled transactions for an account, 1 bundle set is 100 transactions.
NewAddBundles is used to purchase new bundled transactions for an account, 1 bundle set is 100 transactions.
NewAddNft creates an AddNft fio.Action.
No description provided by the author
No description provided by the author
No description provided by the author
NewBurnExpired will return a burnexpired action.
NewBurnExpiredRange will return a burnexpired action.
No description provided by the author
NewCancelFndReq builds the action to cancel a request that is pending by the payee.
No description provided by the author
NewConnection sets up the API interface for interacting with the FIO API.
NewExpDomain is used by a test contract and not available on mainnet
Deprecated: only used in development environments.
NewFundsReq builds the action for providing the result of a off-chain transaction.
No description provided by the author
No description provided by the author
No description provided by the author
NewMsigPropose is provided for consistency, but it will make more sense to use NewSignedMsigPropose to build *simple* multisig proposals since it abstracts several steps.
No description provided by the author
No description provided by the author
No description provided by the author
NewPermissionLevelSlice is a convenience function for quickly building a slice of active permissions.
NewRandomAccount creates a new account with a random key.
NewRecordSend builds the action for providing the result of a off-chain transaction.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewRejectFndReq builds the action to reject a request.
NewRemAction is an alias for NewRemoveAction.
NewRemAllNft builds an action for RemAllNft.
NewRemNft creates an action for removing NFT mappings.
No description provided by the author
NewRemoveAddrReq allows removal of public token/chain addresses.
NewRemoveAllAddrReq allows removal of ALL public token/chain addresses.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewTransaction wraps eos.NewTransaction.
NewTransfer is unlikely to be called, this is a privileged action
deprecated: internal action, user cannot call.
No description provided by the author
No description provided by the author
NewTransferLockedTokens creates an action used to transfer locked tokens to an account.
NewTransferTokensPubKey builds an eos.Action for sending FIO tokens.
No description provided by the author
NewUpdateAuthSimple just takes a list of accounts and a threshold.
No description provided by the author
No description provided by the author
NewVoteProducer creates a VoteProducer action: note - fioAddress is optional as of FIP-009.
NewVoteProxy creates a VoteProxy action: note - fioAddress is optional as of FIP-009.
NewWifConnect adds convenience by setting everything up, given a WIF and URL.
No description provided by the author
SetTpid will set a package variable that will include the provided TPID in all of the calls that support it.
Tokens is a convenience function for converting from a float for human readability.
UpdateMaxFees refreshes the maxFees map from the on-chain table.
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
copy over CompressionTypes to reduce need additional imports.
copy over CompressionTypes to reduce need additional imports.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
founder tokens: cannot vote until unlocked, can use for fees.
foundation tokens used for giveaways, can only be used to register addresses.
foundation member (wallets/exchanges) incentives: if inhibit unlocking is set, cannot be used, votable until 2nd unlock or if uninhibited.
presale tokens, can vote while locked.
ObtAbiJson defines the ABI format for OBT requests.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Variables
each additional unlock period, 2nd unlock = LockedInitial + LockedIncrement, 3rd = LockedInitial + (2 * LockedIncrement), etc.
percent unlocked each additional period: 1st = 6%, 2nd = 24.8% etc.
initial minutes before first unlock period.
percentage unlocked after first period.
number of unlock periods.
# Structs
Account holds the information for an account, it differs from a regular EOS account in that the account name (Actor) is derived from the public key, and a FIO public key has a different prefix.
AccountResp duplicates the eos.AccountResp accounting for differences in public key format.
Action struct duplicates eos.Action.
AddAction adds a contract action to the list of allowed actions, this is part of the underlying permissions system in FIO that limits general smart-contract functionality.
AddAddress allows a public address of the specific blockchain type to be added to the FIO Address, so that it can be returned using /pub_address_lookup
When adding addresses, only 5 can be added in a single call, and an account is limited to 100 public addresses total.
No description provided by the author
AddNft is used to add an array of NFTs (max 3 per tx).
AllowedAction is an account::action that is allowed to execute by eosio.
AllowedActionsResp holds the response from a get_actions API call, adds 'Allowed' prefix to avoid a conflict with eos libraries caused by an unfortunate choice in endpoint naming.
API struct allows extending the eos.API with FIO-specific functions.
Authority duplicates the eos.Authority accounting for differences in public key format.
No description provided by the author
No description provided by the author
BlockHeaderState holds information about reversible blocks.
No description provided by the author
No description provided by the author
BlockTxidsResp contains a list of transactions in a block.
BpClaim requests payout for a block producer.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
BundleVote is used by block producers to vote for the number of free transactions included when registering or renewing a FIO address.
BundleVoter (table query response) holds information about the block producer voting for the number of free bundled transactions for new or renewed addresses as stored in the fio.fee bundlevotes table.
BurnAddress will destroy an address owned by an account.
BurnExpired is intended to be called by block producers to remove expired domains or addresses from RAM
Deprecated: as of the 2.5.x contracts release this will not work, use BurnExpiredRange instead.
BurnExpiredRange is intended to be called by block producers to remove expired domains or addresses from RAM.
BurnNfts is intended to be called by block producers to remove expired NFT mappings from RAM.
CancelFndReq allows cancelling a previously sent request.
No description provided by the author
No description provided by the author
No description provided by the author
ComputeFees calculates fees based upon votes and multipliers, and updates the fiofees table.
CreateFee is a privileged action that adds a new fee record in the fiofees table.
DomainResp holds the table query lookup result for a domain.
ExpDomain is used by a test contract and not available on mainnet
Deprecated: only used in development environments.
FeeValue is used by block producers to vote on the base cost (before multiplier) for a fee.
No description provided by the author
FeeVote (table query response) holds fee vote information from the fio.fee feevotes table
Deprecated: replaced by FeeVote2.
FeeVote2 (query response) is the new voting table format.
FeeVoter (table query response) holds information about the block producer performing a multiplier vote as stored in the fio.fee feevoters table.
FioFee (table query response) holds the details of an action's fee stored in the fio.fee fiofees table.
FioName holds information for either an address or a domain.
FioNames holds the response when getting fio names or addresses for an account.
FundsReq is a request sent from one user to another requesting funds.
FundsReqTableResp has the most useful fields of what is stored in the fioreqctxts table.
No description provided by the author
FundsResp is a request sent from one user to another requesting funds, it includes the fio_request_id, so should be used when querying against the API endpoint.
GenesisLockedTokens holds information about tokens that were locked at chain genesis.
No description provided by the author
No description provided by the author
No description provided by the author
GetTableRowsOrderRequest extends eos.GetTableRowsRequest by adding a reverse field for sorting on index, not sure if it is something unique to FIO or missing for eos-go, but is very handy for limiting searches.
KeyWeight duplicates the eos.KeyWeight accounting for differences in public key format.
LockPeriods specifies how long a portion of the locked tokens will be locked by seconds and percentage, a slice of these is provided when locking tokens and must total 100%.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
MsigApprove approves a multi-sig proposal.
MsigCancel withdraws a proposal, must be performed by the account that proposed the transaction.
MsigExec will attempt to execute a proposed transaction.
TODO: not sure if this is needed.
MsigInvalidate is used to remove all approvals and proposals for an account.
No description provided by the author
No description provided by the author
MsigProposal is a query response for getting details of a proposed transaction.
MsigPropose is a new proposal.
this also looks potentially incorrect:.
MsigUnapprove withdraws an existing approval for an account.
No description provided by the author
No description provided by the author
No description provided by the author
NftToAdd represents a single NFT.
NftToDelete is an individual NFT that should be removed from existing mappings, used by RemNft, The server will validate: chain_code: Min chars: 1, Max chars: 10, Characters allowed: ASCII a-z0-9, Case-insensitive contract_address: Min chars: 1, Max chars: 128 token_id: Token ID of NFT.
No description provided by the author
No description provided by the author
ObtRequestContent holds details for requesting funds.
PayTpidRewards is used for wallets "technology provided id" to claim incentive rewards.
No description provided by the author
No description provided by the author
Permission duplicates the eos.Permission accounting for differences in public key format.
Producer is a modification of the corresponding eos-go structure.
No description provided by the author
Producers is a modification of the corresponding eos-go structure.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
RegAddress Registers a FIO Address on the FIO blockchain.
RegDomain registers a FIO Domain on the FIO blockchain.
No description provided by the author
No description provided by the author
RejectFndReq is a response to a user, denying their request for funds.
RemAllNft removes all NFTs for a FIO Address.
RemNft is used to remove NFTs from an address.
RemoveAction deletes an allowed action from the allowed list.
No description provided by the author
RemoveAllAddrReq is for removing all public addresses associated with a FIO address.
RenewAddress extends the expiration of an address by a year, and refreshes the bundle.
RenewDomain extends the expiration of a domain for a year.
No description provided by the author
RewardsPaid is privileged.
No description provided by the author
SetDomainPub changes the permissions for a domain, allowing (or not) anyone to register an address.
SetFeeMult is used by block producers to vote for the fee multiplier used for calculating rewards.
SetFeeVote is used by block producers to adjust the fee for an action, it is possible that not all fees will fit into a single transaction and may require multiple calls.
TokenPubAddr holds *publicly* available token information for a FIO address, allowing anyone to lookup an address.
Transfer is a privileged call, and not normally used for sending tokens, use TransferTokensPubKey instead.
TransferAddress (future) transfers ownership of a FIO address.
TransferDom (future) transfers ownership of a domain.
No description provided by the author
TransferTokensPubKey is used to send FIO tokens to a public key.
TxOptions wraps eos.TxOptions.
No description provided by the author
No description provided by the author
UpdateBounty is privileged.
UpdateTpid is a privileged call.
VoteProducer votes for a producer.
No description provided by the author
WrapExecute wraps a transaction to be executed with specific permissions via eosio.wrap NOTE: this is not working as expected, use caution.
# Type aliases
Address is a FIO address, which should be formatted as 'name@domain'.
MsigTransactionHeader is an alias for consistent naming.
Name wraps eos.Name for convenience and less imports for client.
No description provided by the author
PermissionLevel wraps eos-go's type to add member functions.
ProducerLocation valid values are 10-80 in increments of 10.