Datatoken Interface Tech Details
Technical details about Datatoken functions
Datatoken contract interface is like the superhero that kicks off the action-packed adventure of contract calls! It's here to save the day by empowering us to unleash the mighty powers of dispensers, fixed rate exchanges, and initializing orders. For this page, we present the utilitary functions that embark you on the Ocean journey.
Create Dispenser
create_dispenser(
self,tx_dict: dict,max_tokens: Optional[Union[int, str]] = None,max_balance: Optional[Union[int, str]] = None,with_mint: Optional[bool] = True)
Through datatoken, you can deploy a new dispenser schema which is used for creating free assets, because its behaviour is similar with a faucet. ⛲
It is implemented in DatatokenBase, inherited by Datatoken2, so it can be called within both instances.
Parameters
tx_dict- is the configurationdictionaryfor that specific transaction. Usually fordevelopmentwe include just thefromwallet, but for remote networks, you can provide gas fees, required confirmations for that block etc.max_tokens- maximum amount of tokens to dispense in wei. The default is a large number.max_balance- maximum balance of requester in wei. The default is a large number.with_mint- boolean,trueif we want to allow the dispenser to be a minter as default value
Returns
str
Return value is a hex string which denotes the transaction hash of dispenser deployment.
Defined in
Dispense Datatokens
dispense(
self,amount: Union[int, str],tx_dict: dict)
This function is used to retrieve funds or datatokens for an user who wants to start an order.
It is implemented in DatatokenBase, so it can be called within Datatoken class.
Parameters
amount- amount of datatokens to be dispensed in wei (int or string format)tx_dict- is the configurationdictionaryfor that specific transaction. Usually fordevelopmentwe include just thefromwallet, but for remote networks, you can provide gas fees, required confirmations for that block etc.
Returns
str
Return value is a hex string which denotes the transaction hash of dispensed datatokens, like a proof.
Defined in
Dispense Datatokens & Order
dispense_and_order(
self,consumer: str,service_index: int,provider_fees: dict,transaction_parameters: dict,consume_market_fees=None) ->str
This function is used to retrieve funds or datatokens for an user who wants to start an order.
It is implemented in Datatoken2, so it can be called within Datatoken2 class (using the enterprise template).
Parameters
consumer- address of the consumer wallet that needs fundingservice_index- service index as int for identifying the service that you want to further callstart_order.transaction_parameters- is the configurationdictionaryfor that specific transaction. Usually fordevelopmentwe include just thefromwallet, but for remote networks, you can provide gas fees, required confirmations for that block etc.consume_market_fees-TokenInfoobject which contains the consume market fee amount, address & token address. If it is not explicitly specified, by default it has an emptyTokenInfoobject.
Returns
str
Return value is a hex string which denotes the transaction hash of dispensed datatokens, like a proof of starting order.
Defined in
Dispenser Status
dispenser_status(
self) ->DispenserStatus
Returns
DispenserStatus
Returns a DispenserStatus object returned from Dispenser.sol::status(dt_addr) which is composed of:
bool active
address owner
bool isMinter
uint256 maxTokens
uint256 maxBalance
uint256 balance
address allowedSwapper
These are Solidity return values & types, but uint256 means int in Python and address is a string instance.
For tips & tricks, check this section from the README.
It is implemented in DatatokenBase, inherited by Datatoken2, so it can be called within both instances.
Defined in
Create Fixed Rate Exchange
create_exchange(
self,rate: Union[int, str],base_token_addr: str,tx_dict: dict,owner_addr: Optional[str] = None,publish_market_fee_collector: Optional[str] = None, publish_market_fee: Union[int, str] = 0,allowed_swapper: str = ZERO_ADDRESS,full_info: bool = False) ->Union[OneExchange, tuple]
It is implemented in DatatokenBase, inherited by Datatoken2, so it can be called within both instances.
For this datatoken, create a single fixed-rate exchange (OneExchange).
This wraps the smart contract method Datatoken.createFixedRate() with a simpler interface.
Parameters
rate- how many base tokens does 1 datatoken cost? In wei or stringbase_token_addr- e.g. OCEAN addresstx_dict- is the configurationdictionaryfor that specific transaction. Usually fordevelopmentwe include just thefromwallet, but for remote networks, you can provide gas fees, required confirmations for that block etc.
Optional parameters
owner_addr- owner of the datatokenpublish_market_fee_collector- fee going to publish market addresspublish_market_fee- in wei or string, e.g.int(1e15)or"0.001 ether"allowed_swapper- ifZERO_ADDRESS, anyone can swapfull_info- return justOneExchange, or(OneExchange, <other info>)
Returns
exchange- OneExchange(maybe)
tx_receipt
Defined in
Buy Datatokens & Order
buy_DT_and_order(
self,consumer: str,service_index: int,provider_fees: dict,exchange: Any,transaction_parameters: dict,consume_market_fees=None) ->str
This function is used to retrieve funds or datatokens for an user who wants to start an order.
It is implemented in Datatoken class and it is also inherited in Datatoken2 class.
Parameters
consumer- address of the consumer wallet that needs fundingservice_index- service index as int for identifying the service that you want to further callstart_order.transaction_parameters- is the configurationdictionaryfor that specific transaction. Usually fordevelopmentwe include just thefromwallet, but for remote networks, you can provide gas fees, required confirmations for that block etc.consume_market_fees-TokenInfoobject which contains the consume market fee amount, address & token address. If it is not explicitly specified, by default it has an emptyTokenInfoobject.
Returns
str
Return value is a hex string for transaction hash which denotes the proof of starting order.
Defined in
Get Exchanges
get_exchanges(
self) ->list
Returns
list
Returns List[OneExchange] - all the exchanges for this datatoken.
It is implemented in DatatokenBase, inherited by Datatoken2, so it can be called within both instances.
Defined in
Start Order
start_order(
self,consumer: str,service_index: int,provider_fees: dict,transaction_parameters: dict,consume_market_fees=None) ->str
Starting order of a certain datatoken.
It is implemented in Datatoken class and it is also inherited in Datatoken2 class.
Parameters
consumer- address of the consumer wallet that needs fundingservice_index- service index as int for identifying the service that you want to applystart_order.provider_fees- dictionary which includes provider fees generated wheninitializeendpoint fromProviderwas called.transaction_parameters- is the configurationdictionaryfor that specific transaction. Usually fordevelopmentwe include just thefromwallet, but for remote networks, you can provide gas fees, required confirmations for that block etc.consume_market_fees-TokenInfoobject which contains the consume market fee amount, address & token address. If it is not explicitly specified, by default it has an emptyTokenInfoobject.
Returns
str
Return value is a hex string for transaction hash which denotes the proof of starting order.
Defined in
Reuse Order
reuse_order(
self,order_tx_id: Union[str, bytes],provider_fees: dict,transaction_parameters: dict) ->str
Reusing an order from a certain datatoken.
It is implemented in Datatoken class and it is also inherited in Datatoken2 class.
Parameters
order_tx_id- transaction hash of a previous order, string or bytes format.provider_fees- dictionary which includes provider fees generated wheninitializeendpoint fromProviderwas called.transaction_parameters- is the configurationdictionaryfor that specific transaction. Usually fordevelopmentwe include just thefromwallet, but for remote networks, you can provide gas fees, required confirmations for that block etc.
Returns
str
Return value is a hex string for transaction hash which denotes the proof of reusing order.
Defined in
Last updated
Was this helpful?

