Prepare user wallet for betting
After you retrieved games and markets, you can start to create a betting flow. But before your users can start to place their bets, they need to prepare their wallets for betting with the following steps:
Top up the native currency
The user needs some small amount of native currency to mint test tokens and give an approval to our Relayer smart contract for spending his betting tokens.
Currently, we are live in Polygon Amoy testnet that's native currency is MATIC
.
To claim some amount for tests, you can use one of the following faucets:
- https://www.alchemy.com/faucets/polygon-amoy (opens in a new tab)
- https://faucet.polygon.technology/ (opens in a new tab)
or just search for polygon amoy testnet faucet
.
Claim test tokens
Bets are placed in ERC20 tokens, currently we support custom AZUSD
in Polygon Amoy testnet.
The contract address of this token is 0xf028b2dd00e20a8d9db3964a5feb0633d2ee46cd
(opens in a new tab).
Before a user can start betting, he needs to claim some amount of this token by calling claim
write method.
Each user can receive 1000 AZUSD once every 24 hours. Users can check if they are eligible to claim the token
right now by using the availableToClaim
read method, which will return true
if they can claim and false
if they cannot.
We recommend you as a frontend operator to create a convenient interface to do that in 1 click and claim
1000 AZUSD
to the user's wallet.
Relayer fee
In our live betting architecture users don't make transactions, they just sign a message that contains all the bet information and place an order. This order is then being executed by a Relayer - special backend service for transactions broadcasting.
Instead of charging a fee in native tokens when a user sends a transaction, the Relayer
uses the same tokens as the ones in which the bet is placed.
We've Implemented API for retrieval Relayer
fee amount:
// For pre-production
const apiUrl = 'https://preprod-api.azuro.org/api/v1/public/orders'
// For production
const apiUrl = 'https://api.azuro.org/api/v1/public/orders'
const environment = Environment.PolygonAmoyAZUSD
const response = await fetch(`${apiUrl}/orders/gas?environment=${environment}`)
const { relayerFeeAmount, beautyRelayerFeeAmount }: LiveBetFeeResponse = await response.json()
enum Environment {
GnosisXDAI = 'GnosisXDAI',
PolygonUSDT = 'PolygonUSDT',
PolygonAmoyAZUSD = 'PolygonAmoyAZUSD',
ChilizWCHZ = 'ChilizWCHZ',
ChilizSpicyWCHZ = 'ChilizSpicyWCHZ'
}
type LiveBetFeeResponse = {
gasLimit: number,
gasPrice: number,
betTokenRate: number,
gasPriceInBetToken: number,
slippage: number,
gasAmount: number,
relayerFeeAmount: string,
beautyRelayerFeeAmount: string,
symbol: string,
decimals: number
}
Give a spending approval
The Relayer
uses bet tokens as a fee then spending amount for approval is:
const spendingAmount = relayerFeeAmount + betAmount
This spendingAmount
should be used for spending approval.
Summary
After finishing all the steps above your users is fueled up with a native currency (that he will need to claim his winnings) and some test tokens for betting that are ready to be spent.
Now you can proceed with a betting flow implementation.