Spend Tokens
This endpoint allows you to spend tokens from a holders account.
POSTapi.metal.build/holder/:userId/spend
Spend tokens
This endpoint initiates a token spend from a holders account back to the merchant account.
Required attributes
- Name
tokenAddress
- Type
- string
- Description
The address of the token to spend.
- Name
amount
- Type
- number
- Description
The amount of tokens to spend.
Request
POST
api.metal.build/holder/:userId/spendconst response = await fetch(
`https://api.metal.build/holder/holder_123/spend`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': 'YOUR_SECRET_API_KEY',
},
body: JSON.stringify({
tokenAddress: '0x191d25c061C081583E616d8978eA670f45A803E5',
amount: 123,
}),
}
)
const spend = await response.json()
Response
{
"success": true,
"transactionHash": "0xa8e6093d2e77af2c48c240ea83ee2ae66df1e79a45261dff7a3a3d0c485a771b",
"from": "0x0f88BFFBE6b521CD0E68C094F189D3cE6Ba5468d",
"to": "0xF12d5594039a36bAa5B8ba17c8Af959Ba9CB772E",
"amount": 123,
"tokenAddress": "0x191d25c061C081583E616d8978eA670f45A803E5"
}