Datatoken Interface Tech Details
Technical details about Datatoken functions
Last updated
Was this helpful?
Technical details about Datatoken functions
Last updated
Was this helpful?
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(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 configuration dictionary
for that specific transaction. Usually for development
we include just the from
wallet, 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, true
if 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(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 configuration dictionary
for that specific transaction. Usually for development
we include just the from
wallet, 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_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 funding
transaction_parameters
- is the configuration dictionary
for that specific transaction. Usually for development
we include just the from
wallet, 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 of starting order.
Defined in
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.
It is implemented in DatatokenBase
, inherited by Datatoken2
, so it can be called within both instances.
Defined in
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 string
base_token_addr
- e.g. OCEAN address
tx_dict
- is the configuration dictionary
for that specific transaction. Usually for development
we include just the from
wallet, but for remote networks, you can provide gas fees, required confirmations for that block etc.
Optional parameters
owner_addr
- owner of the datatoken
publish_market_fee_collector
- fee going to publish market address
publish_market_fee
- in wei or string, e.g. int(1e15)
or "0.001 ether"
allowed_swapper
- if ZERO_ADDRESS
, anyone can swap
full_info
- return just OneExchange
, or (OneExchange, <other info>)
Returns
exchange
- OneExchange
(maybe) tx_receipt
Defined in
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 funding
transaction_parameters
- is the configuration dictionary
for that specific transaction. Usually for development
we include just the from
wallet, 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 starting order.
Defined in
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(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 funding
service_index
- service index as int for identifying the service that you want to apply start_order
.
provider_fees
- dictionary which includes provider fees generated when initialize
endpoint from Provider
was called.
transaction_parameters
- is the configuration dictionary
for that specific transaction. Usually for development
we include just the from
wallet, 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 starting order.
Defined in
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 when initialize
endpoint from Provider
was called.
transaction_parameters
- is the configuration dictionary
for that specific transaction. Usually for development
we include just the from
wallet, 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
service_index
- service index as int for identifying the service that you want to further call .
consume_market_fees
- object which contains the consume market fee amount, address & token address. If it is not explicitly specified, by default it has an empty TokenInfo
object.
For tips & tricks, check from the .
service_index
- service index as int for identifying the service that you want to further call .
consume_market_fees
- object which contains the consume market fee amount, address & token address. If it is not explicitly specified, by default it has an empty TokenInfo
object.
consume_market_fees
- object which contains the consume market fee amount, address & token address. If it is not explicitly specified, by default it has an empty TokenInfo
object.