AIOU Chain Docs

AIOU Chain Docs

  • Docs
  • Languages iconEnglish
    • 中文

›Reference

Getting started

  • Overview
  • Quickstart

AIOU Design and Concepts

  • Account
  • Economic model

Smart Contract

  • Smart Contract Quick Start
  • AIOU Blockchain API
  • Update Contract
  • Generate Receipt in Smart Contract
  • Create IRC20 Token

Running AIOU node

  • Join AIOU Network
  • Become Servi Node

Reference

  • API
  • System Contract
  • Economic Contract
  • Token Contract
  • Gas Charge Table

AIOU Javascript SDK

  • AIOU
  • Blockchain
  • KeyPair
  • Transaction

AIOU Tech Internals

  • VM
  • Database
  • Network layer

SystemContract

vote_producer.aiou


Description

The Super Node campaigns for voting.

Info

contract_idvote_producer.aiou
languagejavascript
version1.0.0

API

applyRegister

Apply for registration to become a super node candidate.

Parameter ListParameter Type
Account Namestring
public key base58 encodingstring
Locationstring
Website urlstring
network idstring
is producerbool

applyUnregister

Apply for cancellation.

Parameter ListParameter Type
Account Namestring

unregister

To cancel the registration, you need to call ApplyUnregister first. After the audit is passed, you can call this interface.

Parameter ListParameter Type
Account Namestring

updateProducer

Update registration information.

Parameter ListParameter Type
Account Namestring
public key base58 encodingstring
Locationstring
Website urlstring
network idstring

logInProducer

Go online, indicating that the node is currently available for service.

Parameter ListParameter Type
Account Namestring

logOutProducer

Offline means that the node is currently unable to provide services.

Parameter ListParameter Type
Account Namestring

vote

vote.

Parameter ListParameter Type
Voter Account Namestring
Candidate Account Namestring
Number of votesstring

unvote

Cancel the vote.

Parameter ListParameter Type
Voter Account Namestring
Candidate Account Namestring
Number of votesstring

voterWithdraw

Voters receive bonus awards.

Parameter ListParameter Type
Voter Account Namestring

candidateWithdraw

The contestant receives a bonus award.

Parameter ListParameter Type
Candidate Account Namestring

getVoterBonus

Calculate voter's bonus awards.

Parameter ListParameter Type
Voter Account Namestring

getCandidateBonus

Calculate contestant's bonus award.

Parameter ListParameter Type
Candidate Account Namestring

topupCandidateBonus

recharge aiou to candidates' bonus pool.

Parameter LisParameter Type
Amountstring
Payer Account Namestring

topupVoterBonus

recharge aiou to voters' bonus pool.

Parameter LisParameter Type
Candidate Account Namestring
Amountstring
Payer Account Namestring

vote.aiou


Description

A universal voting contract used to create votes, collect votes, and vote on statistics. You can implement your own voting function based on this contract.

Info

contract_idvote.aiou
languagejavascript
version1.0.0

API

newVote

Create a vote.

Parameter ListParameter TypeRemarks
Vote creator account namestringCreate a vote that requires pledge 1000 AIOU, which will be deducted from the creator account, and the creator account has the admin privilege to vote
Vote Descriptionstring
Voting Settingsjson objectcontains 5 keys:
resultNumber —— number type, number of voting results, maximum 2000;
minVote —— number type, minimum number of votes, candidates with more votes than this number In order to enter the voting result set;
options - array type, candidate set, each item is a string, represents a candidate, the initial can be empty [];
anyOption - bool type, whether to allow The candidate in the non-options collection, passing false means that the user can only cast candidates in the options collection;
freezeTime - number type, cancel the token freeze time, in seconds;

A successful call returns a globally unique vote ID.

addOption

Increase voting options.

Parameter ListParameter TypeRemarks
Vote IDstringID returned by the NewVote interface
Optionsstring
Whether to clear the previous votesbool

removeOption

Delete the voting option, but retain the result of the vote, delete it, and then add this option through AddOption to choose whether to restore the number of votes.

Parameter ListParameter TypeRemarks
Vote IDstringID returned by the NewVote interface
Optionsstring
Whether to force deleteboolfalse means that the option is not deleted when it is in the result set, true means to force delete and update the result set

getOption

Get the votes for the candidate.

Parameter ListParameter TypeRemarks
Vote IDstringID returned by the NewVote interface
Optionsstring

The result is a json object:

keytypenotes
votesstringVotes
deletedboolIs it marked as deleted
clearTimenumberThe block number where the number of votes was last cleared

voteFor

Vote on behalf of others, the AIOU of the voting pledge will be deducted from the agent account.

Parameter ListParameter TypeRemarks
Vote IDstringID returned by the NewVote interface
Agent account namestring
Voter Account Namestring
Optionsstring
Number of votesstring

vote

vote.

Parameter ListParameter TypeRemarks
Vote IDstringID returned by the NewVote interface
Voter Account Namestring
Optionsstring
Number of votesstring

unvote

Cancel the vote.

Parameter ListParameter TypeRemarks
Vote IDstringID returned by the NewVote interface
Voter Account Namestring
Optionsstring
Number of votesstring

getVote

Get an account vote record.

Parameter ListParameter TypeRemarks
Vote IDstringID returned by the NewVote interface
Voter Account Namestring

The result is a json array, each of which is the following object:

keytypenotes
optionstringoptions
votesstringNumber of votes
voteTimenumberBlock number of the last vote
clearedVotesstringNumber of votes cleared

getResult

Get the voting result and return the option of resultNumber before the number of votes.

Parameter ListParameter TypeRemarks
Vote IDstringID returned by the NewVote interface

The result is a json array, each of which is the following object:

keytypenotes
optionstringoptions
votesstringNumber of votes

delVote

Delete the vote and return the AIOU that was created during the voting to the creator account.

Parameter ListParameter TypeRemarks
Vote IDstringID returned by the NewVote interface

auth.aiou


Description

Account system and rights management

Info

contract_idauth.aiou
languagejavascript
version1.0.0

API

signUp

Create an account

Parameter ListParameter Type
Usernamestring
ownerKeystring
activeKeystring

addPermission

Add permissions to an account

Parameter ListParameter Type
Usernamestring
Permission namestring
Permission thresholdnumber

dropPermission

Delete permission

Parameter ListParameter Type
Usernamestring
Permission namestring

assignPermission

Specify permissions for item

Parameter ListParameter Type
Usernamestring
Permissionsstring
itemstring
Weightnumber

revokePermission

Revoke permission

Parameter ListParameter Type
Usernamestring
Permissionsstring
itemstring

addGroup

Add permission group

Parameter ListParameter Type
Usernamestring
Group namestring

dropGroup

Delete permission group

Parameter ListParameter Type
Usernamestring
Group namestring

assignGroup

Specify item to the permission group

Parameter ListParameter Type
Usernamestring
Group namestring
itemstring
Weightnumber

revokeGroup

Revoke the item of the permission group

Parameter ListParameter Type
Usernamestring
Group namestring
itemstring

assignPermissionToGroup

Add permissions to the group

Parameter ListParameter Type
Usernamestring
Permission namestring
Group namestring

revokePermissionInGroup

Delete permissions in a group

Parameter ListParameter Type
Usernamestring
Permission namestring
Group namestring

bonus.aiou


Description

Formal node? Building block reward? Management

Info

contract_idbonus.aiou
languagejavascript
version1.0.0

API

issueContribute

The contribution value is issued and the system automatically calls

Parameter ListParameter Type
datajson

exchangeAIOU

Use the contribution value to redeem AIOU

Parameter ListParameter Type
Account Namestring
Quantitystring

system.aiou


Description

Base system contract for issuing and updating contracts and other basic system functions.

Info

contract_idsystem.aiou
languagenative
version1.0.0

API

setCode (code)

Deploy smart contracts.

Parameter NameParameter DescriptionParameter Type
codeSmart Contract Codestring
Return ValueReturn Value Type
contractIDstring

The smart contract code includes code and smart contract information, such as language and interface definitions. The code parameter supports two formats: json format and protobuf serialization encoding format. For developers, deployment contracts generally do not need to call this interface directly. It is recommended to use iwallet or related language SDK implementation.

When deploying a smart contract, the system automatically calls the init() function of the smart contract. The developer can do some initialization work in the init function.

Return value contractID is the smart contract ID, which is globally unique and generated by the hash of the deployment contract transaction. The contractID starts with "Contract" and consists of uppercase and lowercase letters and numbers. Only one smart contract can be deployed in a transaction.

updateCode (code, data)

Upgrade smart contracts.

Parameter NameParameter DescriptionParameter Type
codeSmart Contract Codestring
dataupgrade function parametersstring
Return valueNone

Upgrade the smart contract, code is the smart contract code, the format is the same as the parameter in SetCode.

When upgrading a smart contract, the system will automatically check the upgrade permission, that is, the can_update(data) function in the contract, and the parameter data is the second parameter in the UpdateCode, if and only if the can_update function exists and the call returns true. The contract upgrade will succeed, otherwise the upgrade will fail and it is determined that there is no upgrade permission.

cancelDelaytx (txHash)

Cancel a delayed transaction, call this function before the execution of the delayed transaction to cancel the delayed transaction.

Parameter NameParameter DescriptionParameter Type
txHashTransaction hashstring
Return valueNone

requireAuth (acc, permission)

Check if the transaction has the permission of the account.

Parameter NameParameter DescriptionParameter Type
accaccount namestring
permissionpermission namestring
Return valueType
okbool

receipt (data)

Generate a transaction receipt, the receipt is stored in the block, and can also be queried through the transaction hash.

Parameter NameParameter DescriptionParameter Type
datareceipt contentstring
Return valueNone

exchange.aiou


Description

Mainly used to sign up an account and transfer to this account, also can be used to transfer to an existing account.

Info

contract_idexchange.aiou
languagejavascript
version1.0.0

API

transfer(tokenSym, to, amount, memo)

create account and transfer

Parameter NameParameter DescriptionParameter Type
tokenSymToken Identifierstring
toToken receiving account, set to empty if create accountstring
amountTransfer amountstring
memoAdditional Information, set to create:{UserName}:{OwnerPublicKey}:{ActivePublicKey} if create accountstring
Return valueNone

When creating an account, the transfer amount must be at least 100 aiou. By default, the newly created account will be pledged with 10aiou of the gas, and 1K bytes of ram will be purchased. The remaining amount will be transferred to the newly created account.

← APIEconomic Contract →
  • vote_producer.aiou
    • Description
    • Info
    • API
  • vote.aiou
    • Description
    • Info
    • API
  • auth.aiou
    • Description
    • Info
    • API
  • bonus.aiou
    • Description
    • Info
    • API
  • system.aiou
    • Description
    • Info
    • API
  • exchange.aiou
    • Description
    • Info
    • API
AIOU Chain Docs
Community
BlogGitHubStar
Facebook Open Source
Copyright © 2021 Your Name or Your Company Name