Skip to main content
Version: 1.0

API References

Overview​

There are currently four endpoints involved in a Gasless API transaction:

Gasless API also includes two additional endpoints to provide a list of supported tokens for each feature:

There is no Gasless Swaps Token List for other chains because we support swapping all tokens on those chains.

Gasless API is supported on the following chains via https://api.0x.org/. Select the chain in your request by providing the corresponding chain id with the 0x-chain-id header.

ChainChain ID
Ethereum (Mainnet)1
Polygon137
Arbitrum42161
Base8453
Optimism10

Signed Orders are Settled by 0x Protocol Smart Contracts​

Once signed orders hit the blockchain,

  • If the orders are swap only, they are settled by 0x Protocol smart contracts directly,
  • For meta-transaction v2 orders, they are settled by the contract MetaTransactionsFeatureV2 and filled by the executeMetaTransactionV2 function, available here.
  • For otc order, they are settled by the contract OtcOrdersFeature and filled by the fillTakerSignedOtcOrderForEth or fillTakerSignedOtcOrder functions, available here.

If the orders are approval and swap, they are settled by permitAndCall contract which handles the approval and swap atomically. The swap would be forwarded to 0x Protocol smart contracts and handled by the same functions.

Addresses of 0x Protocol smart contracts are available here.

Addresses of permitAndCall contracts

NetworkAddress
Ethereum (Mainnet)0x1291c02d288de3de7dc25353459489073d11e1ae
Polygon0x2ddd30fe5c12fc4cd497526f14bf3d1fcd3d5db4

Technical Appendix​

Presenting EIP-712 Signatures for signTypedData​

If you are user facing wallet that shows the users the details of what they are signing, then you will most likely want to use the EIP-712 signing strategy. Some commonly used tools for this include:

In order to do so, you will need the following:

  • domain
  • types
  • primaryType
  • message

The message will be MetaTransactionDataV2 that is returned at the time of /quote. However, you will also need the other fields.

The domain will change per chain, but the name and version fields are consistent. Example:

const domain = {
chainId: 1,
verifyingContract: '0xdef1c0ded9bec7f1a1670819833240f027b25eff',
name: 'ZeroEx',
version: '1.0.0',
};

For types and primaryTypes, it will depend on the message format.

  • For MetaTransactionDataV2

    const primaryType = 'MetaTransactionDataV2';
    const types = {
    EIP712Domain: [
    {
    name: 'name',
    type: 'string',
    },
    {
    name: 'version',
    type: 'string',
    },
    {
    name: 'chainId',
    type: 'uint256',
    },
    {
    name: 'verifyingContract',
    type: 'address',
    },
    ],
    MetaTransactionDataV2: [
    {
    type: 'address',
    name: 'signer',
    },
    {
    type: 'address',
    name: 'sender',
    },
    {
    type: 'uint256',
    name: 'expirationTimeSeconds',
    },
    {
    type: 'uint256',
    name: 'salt',
    },
    {
    type: 'bytes',
    name: 'callData',
    },
    {
    type: 'address',
    name: 'feeToken',
    },
    {
    type: 'MetaTransactionFeeData[]',
    name: 'fees',
    },
    ],
    MetaTransactionFeeData: [
    {
    type: 'address',
    name: 'recipient',
    },
    {
    type: 'uint256',
    name: 'amount',
    },
    ],
    };
  • For OtcOrder

    const primaryType = 'OtcOrder';
    const types = {
    EIP712Domain: [
    {
    name: 'name',
    type: 'string',
    },
    {
    name: 'version',
    type: 'string',
    },
    {
    name: 'chainId',
    type: 'uint256',
    },
    {
    name: 'verifyingContract',
    type: 'address',
    },
    ],
    OtcOrder: [
    {
    type: 'address',
    name: 'makerToken',
    },
    {
    type: 'address',
    name: 'takerToken',
    },
    {
    type: 'uint128',
    name: 'makerAmount',
    },
    {
    type: 'uint128',
    name: 'takerAmount',
    },
    {
    type: 'address',
    name: 'maker',
    },
    {
    type: 'address',
    name: 'taker',
    },
    {
    type: 'address',
    name: 'txOrigin',
    },
    {
    type: 'uint256',
    name: 'expiryAndNonce',
    },
    ],
    };

    More information on signing 0x orders is available here.

Computing a trade hash​

You could / should verify that the hash we provide in our request matches the meta-transaction provided.

For the trade.hash field:

  • If it's a meta-transaction v2, verify that the meta-transaction v2 hashes to the trade.hash: getMetaTransactionV2Hashlink
  • It it's an otc, verify that otc hashes to the trade.hash: getOtcOrderHash link

If you need to call these functions on the 0x smart contracts to validate your code, you may need: