Recent Artilces

BLOG

System Contract

← All Topics

vote_producer.iost


Description

The Super Node campaigns for voting.

Info

contract_idvote_producer.iost
languagejavascript
version1.0.6

API

applyRegister(applicant, pubkey, location, url, netid, isProducer)

Apply for registration to become a node candidate.

Parameter ListParameter TypeRemark
applicantstringThe applicant account name. Calling this interface requires this account’s “vote” permission
pubkeystringNode public key, encoding with base58. The corresponding seckey of this pubkey is used to sign blocks by block producer node. The partner node can pass any value to this parameter.
locationstringThe team location
urlstringThe team homepage
netidstringThe network id of block producer node. The partner node doesn’t need to pass this parameter.
isProducerboolWhether it’s a block producer node.

applyUnregister(applicant)

Apply for cancellation.

Parameter ListParameter TypeRemark
applicantstringThe applicant account name. Calling this interface requires this account’s “vote” permission

unregister(applicant)

Cancel the registration. If you are an approved producer node, you need to call ApplyUnregister first, after the audit is passed, you can call this interface.

Parameter ListParameter TypeRemark
applicantstringThe applicant account name. Calling this interface requires this account’s “vote” permission

updateProducer(account, pubkey, location, url, netid)

Update registration information.

Parameter ListParameter TypeRemark
applicantstringThe applicant account name. Calling this interface requires this account’s “vote” permission
pubkeystringNode public key, encoding with base58. The corresponding seckey of this pubkey is used to sign blocks by block producer node. The partner node can pass any value to this parameter.
locationstringThe team location
urlstringThe team homepage
netidstringThe network id of block producer node. The partner node doesn’t need to pass this parameter.

logInProducer(account)

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

Parameter ListParameter TypeRemark
accountstringThe applicant account name. Calling this interface requires this account’s “vote” permission

logOutProducer(account)

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

Parameter ListParameter TypeRemark
accountstringThe applicant account name. Calling this interface requires this account’s “vote” permission

vote(voter, nodeAccount, amount)

vote for a node.

Parameter ListParameter TypeRemark
voterstringVoter account name. Calling this interface requires this account’s “active” permission
nodeAccountstringNode account name.
amountstringAmount of votes

unvote(voter, nodeAccount, amount)

Cancel the vote.

Parameter ListParameter TypeRemark
voterstringVoter account name. Calling this interface requires this account’s “active” permission
nodeAccountstringNode account name.
amountstringAmount of votes

voterWithdraw(voter)

Voters receive bonus awards.

Parameter ListParameter TypeRemark
voterstringVoter account name. Calling this interface requires this account’s “operate” permission

candidateWithdraw(candidate)

The contestant receives a bonus award.

Parameter ListParameter TypeRemark
candidatestringCandidate account name. Calling this interface requires this account’s “operate” permission

getVoterBonus(voter)

Calculate voter’s available bonus awards.

Parameter ListParameter TypeRemark
voterstringVoter account name.

getCandidateBonus(candidate)

Calculate contestant’s available bonus award.

Parameter ListParameter TypeRemark
candidatestringCandidate account name.

topupCandidateBonus(amount, payer)

Recharge iost to candidates’ bonus pool.

Parameter ListParameter TypeRemark
amountstringThe recharge amount.
payerstringThe payer account name. Calling this interface requires this account’s “transfer” permission

topupVoterBonus(candidate, amount, payer)

Recharge iost to voters’ bonus pool.

Parameter ListParameter TypeRemark
candidatestringCandidate account name.
amountstringThe recharge amount.
payerstringThe payer account name. Calling this interface requires this account’s “transfer” permission

vote.iost


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.iost
languagejavascript
version1.0.1

API

newVote(owner, description, config)

Create a vote.

Parameter ListParameter TypeRemark
ownerstringThe vote creator account name. Creating a vote requires pledge 1000 IOST, which will be deducted from the creator account. Calling this interface requires this account’s “transfer” permission
descriptionstringVote Description
configjson objectThe vote configuration. It contains 6 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;
canVote —— bool type, whether use who isn’t voter creator is allowed to vote

A successful call returns a globally unique vote ID.

setCanVote(voteID, canVote)

Set whether use who isn’t voter creator is allowed to vote.

Calling this interface requires the vote creator's "active" permission.

Parameter ListParameter TypeRemark
voteIDstringID returned by the NewVote interface
canVoteboolWhether use who isn’t voter creator is allowed to vote.

addOption(voteID, option, clearVotes)

Increase voting options.

Calling this interface requires the vote creator's "active" permission.

Parameter ListParameter TypeRemark
voteIDstringID returned by the NewVote interface
optionstringOption
clearVotesboolWhether to clear the previous votes

removeOption(voteID, option, forceDelete)

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.

Calling this interface requires the vote creator's "active" permission.

Parameter ListParameter TypeRemark
voteIDstringID returned by the NewVote interface
optionstringOption
forceDeleteboolWhether to force delete, false 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(voteID, option)

Get the votes for the candidate.

Parameter ListParameter TypeRemark
voteIDstringID returned by the NewVote interface
optionstringOption

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(voteID, payer, voter, option, amount)

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

Parameter ListParameter TypeRemark
voteIDstringID returned by the NewVote interface
payerstringAgent account name, Calling this interface requires this account’s “active” permission.
voterstringVoter account name
optionstringOption
amountstringThe amount of votes

vote(voteID, voter, option, amount)

Vote.

Parameter ListParameter TypeRemark
voteIDstringID returned by the NewVote interface
voterstringVoter account name, Calling this interface requires this account’s “active” permission.
optionstringOption
amountstringThe amount of votes

unvote(voteID, voter, option, amount)

Cancel the vote.

Parameter ListParameter TypeRemark
voteIDstringID returned by the NewVote interface
voterstringVoter account name, Calling this interface requires this account’s “active” permission.
optionstringOption
amountstringThe amount of votes

getVote(voteID, voter)

Get an account vote record.

Parameter ListParameter TypeRemark
voteIDstringID returned by the NewVote interface
voterstringVoter account name

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(voteID)

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

Parameter ListParameter TypeRemark
voteIDstringID returned by the NewVote interface

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

keytypenotes
optionstringoptions
votesstringNumber of votes

delVote(voteID)

Delete the vote and return the iost to the creator account that was pledged when creating the vote.

Calling this interface requires the vote creator's "active" permission.

Parameter ListParameter TypeRemark
voteIDstringID returned by the NewVote interface

auth.iost


Description

Account system and rights management

Info

contract_idauth.iost
languagejavascript
version1.0.0

API

signUp(accountName, ownerKey, activeKey)

Create an account.

Parameter ListParameter TypeRemark
accountNamestringAccount name, whose length should be between 5 and 11 and can only contain characters in [a-z0-9_]
ownerKeystringthe pubkey of owner permission, base58 encoded
activeKeystringthe pubkey of active permission, base58 encoded

addPermission(account, permission, weight)

Add permissions to an account.

Parameter ListParameter TypeRemark
accountstringaccount name. Calling this interface requires this account’s “owner” permission.
permissionstringPermission name
weightnumberPermission threshold

dropPermission(account, permission)

Delete permission

Parameter ListParameter TypeRemark
accountstringaccount name. Calling this interface requires this account’s “owner” permission.
permissionstringPermission name

assignPermission(account, permission, item, weight)

Assign permission to item.

Parameter ListParameter TypeRemark
accountstringaccount name. Calling this interface requires this account’s “owner” permission.
permissionstringpermission name
itemstringpermission owner, could be pubkey of another account name
Weightnumberpermission weight

revokePermission(account, permission, item)

Revoke permission

Parameter ListParameter TypeRemark
accountstringaccount name. Calling this interface requires this account’s “owner” permission.
permissionstringpermission name
itemstringpermission owner, could be pubkey of another account name

addGroup(account, group)

Add permission group

Parameter ListParameter TypeRemark
accountstringaccount name. Calling this interface requires this account’s “owner” permission.
groupstringgroup name

dropGroup(account, group)

Delete permission group

Parameter ListParameter TypeRemark
accountstringaccount name. Calling this interface requires this account’s “owner” permission.
groupstringgroup name

assignGroup(account, group, item, weight)

Assign item to a permission group

Parameter ListParameter TypeRemark
accountstringaccount name. Calling this interface requires this account’s “owner” permission.
groupstringgroup name
itemstringpermission owner, could be pubkey of another account name
Weightnumberpermission weight

revokeGroup(account, group, item)

Revoke the item of the permission group

Parameter ListParameter TypeRemark
accountstringaccount name. Calling this interface requires this account’s “owner” permission.
groupstringgroup name
itemstringpermission owner, could be pubkey of another account name

assignPermissionToGroup(account, permission, group)

Add permissions to the group

Parameter ListParameter TypeRemark
accountstringaccount name. Calling this interface requires this account’s “owner” permission.
permissionstringpermission name
groupstringgroup name

revokePermissionInGroup(account, permission, group)

Delete permissions in a group

Parameter ListParameter TypeRemark
accountstringaccount name. Calling this interface requires this account’s “owner” permission.
permissionstringpermission name
groupstringgroup name

bonus.iost


Description

This smart contract is for block reward sending and receiving.

Info

contract_idbonus.iost
languagejavascript
version1.0.2

API

exchangeIOST(account, amount)

Use the contribution value to exchange iost.

Parameter ListParameter TypeRemark
accountstringaccount name. Calling this interface requires this account’s “active” permission.
amountstringthe amount of iost to exchange, “0” represents all

system.iost


Description

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

Info

contract_idsystem.iost
languagenative
version1.0.0

API

setCode(code)

Deploy smart contracts.

Parameter ListParameter TypeRemark
codestringSmart contract code
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 ListParameter TypeRemark
codestringSmart contract code
datastringUpgrade function parameters

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 ListParameter TypeRemark
txHashstringTransaction hash

requireAuth(acc, permission)

Check if the transaction has the permission of the account.

Parameter ListParameter TypeRemark
accstringaccount name
permissionstringpermission name
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 ListParameter TypeRemark
datastringreceipt content

exchange.iost


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.iost
languagejavascript
version1.0.0

API

transfer(tokenSym, to, amount, memo)

create account and transfer

Parameter ListParameter TypeRemark
tokenSymstringToken symbol
tostringToken receiving account, set to empty if create account
amountstringTransfer amount
memostringAdditional Information, set to create:{UserName}:{OwnerPublicKey}:{ActivePublicKey} if create account

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

Last Updated On August 01, 2019
Vote For Us
Vote for IOST Watch and receive Daily IOST reward