I'm trying out the new 0x Fantom integration API, in order to automate some trading tasks.

According to this, using the Swap-API from 0x returns a transaction for a quote, which just needs to be signed & sent to the network: https://0x.org/docs/api#get-swapv1quote , quote:

Get an easy-to-consume quote for buying or selling any token. The return format is a valid unsigned Ethereum transaction and can be submitted directly to an Ethereum node to complete the swap.

But when I actually get the result from a (working) quote, the data I receive cannot be treated as unsigned transaction: signing via web3 (Python) complains that there's unrecognized fields.

Sample code:

get_quote_url = 'https://fantom.api.0x.org/swap/v1/quote?sellToken=DAI&buyToken=WETH&sellAmount=10000000000000000000'
response = requests.get(get_quote_url) 
quote = response.json()
my_sell_DAI_for_WETH_quote['nonce'] = w3.eth.get_transaction_count(my_address)
w3.eth.account.signTransaction(my_sell_DAI_for_WETH_quote, my_address_privkey)

This results in the error:

"TypeError: Transaction must not include unrecognized fields: {'allowanceTarget', 'orders', 'estimatedGas', 'sources', 'minimumProtocolFee', 'protocolFee', 'sellTokenToEthRate', 'buyTokenToEthRate', 'sellAmount', 'buyAmount', 'guaranteedPrice', 'buyTokenAddress', 'price', 'sellTokenAddress'}"

What am I missing here?

1 Answer 1


It's valid for most javascript web3 libraries, which typically ignore unused fields. YMMV with Python. It looks like you might just need to prune those excess fields.

  • Two of the suggested fields it doesnt recognize are: > 'sellAmount', 'buyAmount', If I leave them both out, how does it even still know how much to swap? I think I might be doing something wrong here... thanks, will try anyways
    – JohnnyF
    Commented Nov 5, 2021 at 11:31
  • All of that information is encoded in the data field. Commented Nov 5, 2021 at 14:41
  • Confirmed, removing the fields lets me sign it. Ran into other problems still, for which I am unsure what it is: the field "gas", "gasPrice" and "value" are all returned from the 0x API as string, must be converted to integer before it can be signed. The "to" address is a non-checksum-address and must be converted to a checksum-address as well, before signing the transaction works.
    – JohnnyF
    Commented Nov 5, 2021 at 20:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.