logo

Token Converter Contract

#

Using this contract can build a connection between the base token and other tokens created on the chain. After building the connection, users can trade tokens with the Bancor model. You can find detailed information about Bancor in the AElf Economic System White Paper. Implement aelf Standards ACS1.

Contract Methods#

AElf.Standards.ACS1#

Method NameRequest TypeResponse TypeDescription
SetMethodFeeacs1.MethodFeesgoogle.protobuf.EmptySet the method fees for the specified method. Note that this will override all fees of the method.
ChangeMethodFeeControllerAuthorityInfogoogle.protobuf.EmptyChange the method fee controller, the default is parliament and default organization.
GetMethodFeegoogle.protobuf.StringValueacs1.MethodFeesQuery method fee information by method name.
GetMethodFeeControllergoogle.protobuf.EmptyAuthorityInfoQuery the method fee controller.

Contract Types#

AElf.Contracts.TokenConverter#

TokenConverter.BuyInput#

FieldTypeDescriptionLabel
symbolstringThe token symbol you want to buy.
amountint64The amount you want to buy.
pay_limitint64Limit of cost. If the token required for buy exceeds this value, the buy will be abandoned. And 0 is no limit.

TokenConverter.Connector#

FieldTypeDescriptionLabel
symbolstringThe token symbol.
virtual_balanceint64The virtual balance for base token.
weightstringThe calculated weight value for this Connector.
is_virtual_balance_enabledboolWhether to use Virtual Balance.
is_purchase_enabledboolWhether the connector is enabled.
related_symbolstringIndicates its related connector, the pair connector includes a new created token connector and the base token connector.
is_deposit_accountboolIndicates if the connector is base token connector.

TokenConverter.DepositInfo#

FieldTypeDescriptionLabel
need_amountint64How much more base Token is needed as the deposit.
amount_out_of_token_convertint64How many tokens are not on the TokenConvert address.

TokenConverter.InitializeInput#

FieldTypeDescriptionLabel
base_token_symbolstringBase token symbol, default is the native token symbol.
fee_ratestringThe fee rate for buy/sell.
connectorsConnectorThe default added connectors.repeated

TokenConverter.PairConnector#

FieldTypeDescriptionLabel
resource_connectorConnectorThe connector of the specified token.
deposit_connectorConnectorThe related connector.

TokenConverter.PairConnectorParam#

FieldTypeDescriptionLabel
resource_connector_symbolstringThe token symbol.
resource_weightstringThe weight value of this token in the Bancor model.
native_virtual_balanceint64This token corresponds to the value of base token.
native_weightstringThe weight value of base token in Bancor model.

TokenConverter.SellInput#

FieldTypeDescriptionLabel
symbolstringThe token symbol you want to sell.
amountint64The amount you want to sell.
receive_limitint64Limits on tokens obtained by selling. If the token obtained is less than this value, the sale will be abandoned. And 0 is no limit.

TokenConverter.ToBeConnectedTokenInfo#

FieldTypeDescriptionLabel
token_symbolstringThe token symbol.
amount_to_token_convertint64Specifies the number of tokens to convert to the TokenConvert contract.

TokenConverter.TokenBought#

TokenConverter.TokenSold#

FieldTypeDescriptionLabel
symbolstringThe token symbol sold.
sold_amountint64The amount sold.
base_amountint64The total received of the base token.
fee_amountint64The fee amount.

TokenConverter.TokenSymbol#

FieldTypeDescriptionLabel
symbolstringThe token symbol.

AElf.Standards.ACS1#

acs1.MethodFee#

FieldTypeDescriptionLabel
symbolstringThe token symbol of the method fee.
basic_feeint64The amount of fees to be charged.

acs1.MethodFees#

FieldTypeDescriptionLabel
method_namestringThe name of the method to be charged.
feesMethodFeeList of fees to be charged.repeated
is_size_fee_freeboolOptional based on the implementation of SetMethodFee method.

AElf.Types#

aelf.Address#

FieldTypeDescriptionLabel
valuebytes

aelf.BinaryMerkleTree#

aelf.Hash#

FieldTypeDescriptionLabel
valuebytes

aelf.LogEvent#

FieldTypeDescriptionLabel
addressAddressThe contract address.
namestringThe name of the log event.
indexedbytesThe indexed data, used to calculate bloom.repeated
non_indexedbytesThe non indexed data.

aelf.MerklePath#

FieldTypeDescriptionLabel
merkle_path_nodesMerklePathNodeThe merkle path nodes.repeated

aelf.MerklePathNode#

FieldTypeDescriptionLabel
hashHashThe node hash.
is_left_child_nodeboolWhether it is a left child node.

aelf.SInt32Value#

FieldTypeDescriptionLabel
valuesint32

aelf.SInt64Value#

FieldTypeDescriptionLabel
valuesint64

aelf.ScopedStatePath#

FieldTypeDescriptionLabel
addressAddressThe scope address, which will be the contract address.
pathStatePathThe path of contract state.

aelf.SmartContractRegistration#

aelf.StatePath#

FieldTypeDescriptionLabel
partsstringThe partial path of the state path.repeated

aelf.Transaction#

FieldTypeDescriptionLabel
fromAddressThe address of the sender of the transaction.
toAddressThe address of the contract when calling a contract.
ref_block_numberint64The height of the referenced block hash.
ref_block_prefixbytesThe first four bytes of the referenced block hash.
method_namestringThe name of a method in the smart contract at the To address.
paramsbytesThe parameters to pass to the smart contract method.
signaturebytesWhen signing a transaction it’s actually a subset of the fields: from/to and the target method as well as the parameter that were given. It also contains the reference block number and prefix.

aelf.TransactionExecutingStateSet#

FieldTypeDescriptionLabel
writesTransactionExecutingStateSet.WritesEntryThe changed states.repeated
readsTransactionExecutingStateSet.ReadsEntryThe read states.repeated
deletesTransactionExecutingStateSet.DeletesEntryThe deleted states.repeated

aelf.TransactionExecutingStateSet.DeletesEntry#

FieldTypeDescriptionLabel
keystring
valuebool

aelf.TransactionExecutingStateSet.ReadsEntry#

FieldTypeDescriptionLabel
keystring
valuebool

aelf.TransactionExecutingStateSet.WritesEntry#

FieldTypeDescriptionLabel
keystring
valuebytes

aelf.TransactionResult#

FieldTypeDescriptionLabel
transaction_idHashThe transaction id.
statusTransactionResultStatusThe transaction result status.
logsLogEventThe log events.repeated
bloombytesBloom filter for transaction logs. A transaction log event can be defined in the contract and stored in the bloom filter after the transaction is executed. Through this filter, we can quickly search for and determine whether a log exists in the transaction result.
return_valuebytesThe return value of the transaction execution.
block_numberint64The height of the block hat packages the transaction.
block_hashHashThe hash of the block hat packages the transaction.
errorstringFailed execution error message.

aelf.TransactionResultStatus#

AuthorityInfo#

FieldTypeDescriptionLabel
contract_addressaelf.AddressThe contract address of the controller.
owner_addressaelf.AddressThe address of the owner of the contract.

Edited on: 16 July 2024 04:28:53 GMT+0