The stablecoin.services api at https://api.stablecoin.services is a relaying service which accepts signed messages as specified by the DACH contract and submits them to the ethereum blockchain.
Front end developers can integrate with this api to provide gas-free version of the following operations:
- Dai transfers
- Chai transfers
- Dai -> Eth uniswap trades
- Chai -> Eth uniswap trades
- Dai <-> Chai conversion
Instead, a dai or chai fee must be provided to pay for the cost of relaying. The necessary fee for an operation can be determined by calling the <operation>/fee
GET method.
First time users which have not yet given the Dach contract an allowance can do so by using the <operation>WithPermit
version of the appropriate operation. This first submits a permit
message to the appropriate token contract before initiating the cheque, swap or conversion.
The api provides the following methods:
Table of Contents
The api accepts ERC712 signed messages. There are 5 different kinds of messages, permit
, cheque
, swap
, join
, and exit
. For an example of how to generate ERC712 signed messages for these, you can look at the stablecoin.services source at https://github.com/MrChico/stablecoin.services/
The permit comes in two forms, a dai.permit
and a chai.permit
, both comprised of the following fields:
Holder
, theaddress
which is giving permission.Spender
, theaddress
to which permission is given.expiry
(optional with default :=0
), the time thepermit
can no longer be submitted.allowed
(optional with default :=true
), whether or not permission is given. Must betrue
.v
r
s
, the signature details of the ERC712dai
orchai
permit
.
A cheque
consists of:
sender
, theaddress
sending dai/chai.receiver
, theaddress
receiving dai/chai.amount
, astring
ornumber
representing the the dai/chai to be spent (with 18 decimal places).nonce
, (optional with default :=0
) astring
ornumber
representing the dach nonce of thesender
.fee
, astring
ornumber
value of dai/chai to be given to the relayer. Must be at leastcheque/fee
.relayer
, anaddress
to which the fee will be delivered. Must be "0x09748c5b809fF520C7b85e92d5C3B73aCF940f7b".v
r
s
, signature details of the ERC712dai
orchai
Cheque
.
A swap
consists of:
sender
, theaddress
sending dai/chai.amount
, astring
ornumber
representing the the dai/chai to sold on in the uniswap contract (with 18 decimal places).min_eth
, astring
ornumber
representing the minimal eth to be received.nonce
, (optional with default :=0
) astring
ornumber
representing the dach nonce of thesender
.fee
, astring
ornumber
value of dai/chai to be given to the relayer. Must be at leastswap/fee
.relayer
, anaddress
to which the fee will be delivered. Must be "0x09748c5b809fF520C7b85e92d5C3B73aCF940f7b".v
r
s
, signature details of the ERC712dai
orchai
swap
.
A join
or exit
consists of:
sender
, theaddress
converting dai to chai or vice versa.receiver
, theaddress
receiving dai/chai.amount
, astring
ornumber
representing the the dai/chai to be spent (with 18 decimal places).nonce
, (optional with default :=0
) astring
ornumber
representing the dach nonce of thesender
.fee
, astring
ornumber
value of dai/chai to be given to the relayer. Must be at leastjoin/fee
.relayer
, anaddress
to which the fee will be delivered. Must be "0x09748c5b809fF520C7b85e92d5C3B73aCF940f7b".v
r
s
, signature details of the ERC712chaiJoin
orchaiExit
.
None.
The minimal dai fee required for a daiChequeWithPermit
to be accepted (with 18 decimal places).
None.
The minimal dai fee required for a daiSwapWithPermit
to be accepted (with 18 decimal places).
None.
The minimal chai fee required for a chaiChequeWithPermit
to be accepted (with 18 decimal places).
None.
The minimal chai fee required for a chaiSwapWithPermit
to be accepted (with 18 decimal places).
None.
The minimal dai fee required for a chaiJoinWithPermit
to be accepted (with 18 decimal places).
- Note that the
permit
required for thechaiJoinWithPermit
operation is that of the Dai contract.
None.
The minimal chai fee required for a chaiExitWithPermit
to be accepted (with 18 decimal places).
- Note that the
permit
required for thechaiExitWithPermit
operation is that of the Chai contract
None.
The minimal dai fee required for a daiCheque
to be accepted (with 18 decimal places).
None.
The minimal dai fee required for a daiSwap
to be accepted (with 18 decimal places).
None.
The minimal chai fee required for a chaiCheque
to be accepted (with 18 decimal places).
None.
The minimal chai fee required for a chaiSwap
to be accepted (with 18 decimal places).
None.
The minimal dai fee required for a chaiJoin
to be accepted (with 18 decimal places).
None.
The minimal chai fee required for a chaiExit
to be accepted (with 18 decimal places).
A json object containing a dai permit
and dai cheque
.
A json object containing the fields success
and message
, where message
either contains an error message, or, if success
is true
, a chequeHash
containing the hash of the transaction submitting the permit
and cheque
.
A json object containing a dai permit
and dai swap
.
A json object containing the fields success
and message
, where message
either contains an error message, or, if success
is true
, a swapHash
containing the hash of the transaction submitting the permit
and swap
.
A json object containing a chai permit
and chai cheque
.
A json object containing the fields success
and message
, where message
either contains an error message, or, if success
is true
, a chequeHash
containing the hash of the transaction submitting the permit
and cheque
.
A json object containing a chai permit
and chai swap
.
A json object containing the fields success
and message
, where message
either contains an error message, or, if success
is true
, a swapHash
containing the hash of the transaction submitting the permit
and swap
.
A json object containing a dai permit
and chai Join
.
A json object containing the fields success
and message
, where message
either contains an error message, or, if success
is true
, a joinHash
containing the hash of the transaction submitting the permit
and join
.
A json object containing a chai permit
and chai Exit
.
A json object containing the fields success
and message
, where message
either contains an error message, or, if success
is true
, a exitHash
containing the hash of the transaction submitting the permit
and exit
.
A json object containing a dai cheque
.
A json object containing the fields success
and message
, where message
either contains an error message, or, if success
is true
, a chequeHash
containing the hash of the transaction submitting the cheque
.
A json object containing a dai swap
.
A json object containing the fields success
and message
, where message
either contains an error message, or, if success
is true
, a swapHash
containing the hash of the transaction submitting the swap
.
A json object containing a chai cheque
.
A json object containing the fields success
and message
, where message
either contains an error message, or, if success
is true
, a chequeHash
containing the hash of the transaction submitting the cheque
.
A json object containing a chai swap
.
A json object containing the fields success
and message
, where message
either contains an error message, or, if success
is true
, a swapHash
containing the hash of the transaction submitting the swap
.
A json object containing a chai Join
.
A json object containing the fields success
and message
, where message
either contains an error message, or, if success
is true
, a joinHash
containing the hash of the transaction submitting the join
.
A json object containing a chai Exit
.
A json object containing the fields success
and message
, where message
either contains an error message, or, if success
is true
, a exitHash
containing the hash of the transaction submitting the exit
.