cURL
curl --request POST \
--url https://api.openformat.tech/v1/credit/approve \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"chain": "arbitrum-sepolia",
"token_id": "0xd1f09c70f6f2838a3ab6209c1465af68594667ec",
"holder_address": "0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9",
"spender_address": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
"amount": 123
}
'import requests
url = "https://api.openformat.tech/v1/credit/approve"
payload = {
"chain": "arbitrum-sepolia",
"token_id": "0xd1f09c70f6f2838a3ab6209c1465af68594667ec",
"holder_address": "0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9",
"spender_address": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
"amount": 123
}
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
chain: 'arbitrum-sepolia',
token_id: '0xd1f09c70f6f2838a3ab6209c1465af68594667ec',
holder_address: '0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9',
spender_address: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
amount: 123
})
};
fetch('https://api.openformat.tech/v1/credit/approve', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.openformat.tech/v1/credit/approve",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'chain' => 'arbitrum-sepolia',
'token_id' => '0xd1f09c70f6f2838a3ab6209c1465af68594667ec',
'holder_address' => '0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9',
'spender_address' => '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
'amount' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.openformat.tech/v1/credit/approve"
payload := strings.NewReader("{\n \"chain\": \"arbitrum-sepolia\",\n \"token_id\": \"0xd1f09c70f6f2838a3ab6209c1465af68594667ec\",\n \"holder_address\": \"0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9\",\n \"spender_address\": \"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266\",\n \"amount\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.openformat.tech/v1/credit/approve")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"chain\": \"arbitrum-sepolia\",\n \"token_id\": \"0xd1f09c70f6f2838a3ab6209c1465af68594667ec\",\n \"holder_address\": \"0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9\",\n \"spender_address\": \"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266\",\n \"amount\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.openformat.tech/v1/credit/approve")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"chain\": \"arbitrum-sepolia\",\n \"token_id\": \"0xd1f09c70f6f2838a3ab6209c1465af68594667ec\",\n \"holder_address\": \"0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9\",\n \"spender_address\": \"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266\",\n \"amount\": 123\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"unsignedTransaction": {
"to": "0x014b680bed2433b1861239cf812dbe660fe339f2",
"data": "0x609512c90000000000000000000000009574e9ba92cb0966c9d2ff1a9ab9e11949b9b873000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000de0b6b3a7640000647261676f6e5f736c6179656400000000000000000000000000000000000000414354494f4e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000",
"maxPriorityFeePerGas": "1020840008",
"maxFeePerGas": "1035102698",
"gas": "476358",
"gasLimit": "476358",
"nonce": 36,
"chainId": 31337,
"type": 2
}
}
{
"success": false,
"error": {
"code": "validation_error",
"message": "Some parameters are invalid",
"issues": [
{
"code": "too_small",
"message": "Number must be greater than 0",
"parameter": "amount",
"path": "amount"
}
]
}
}
{
"success": false,
"error": {
"code": "token_not_found",
"message": "Credit token not found"
}
}
{
"success": false,
"error": {
"code": "transaction_error",
"message": "There was an error in the blockchain transaction",
"transaction_error": {
"reason": "Error: ERC20Base__ApproveToZeroAddress() ",
"message": "The contract function \"approve\" reverted.",
"detailsMessage": "Error: ERC20Base__ApproveToZeroAddress() Contract Call: address: 0x014b680bed2433b1861239cf812dbe660fe339f2\n function: approve(address spender, uint256 amount)\n args: (0x0000000000000000000000000000000000000000, 1000000000000000000)\n sender: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
"contract_address": "0x014b680bed2433b1861239cf812dbe660fe339f2",
"chain_id": 31337,
"function_name": "approve",
"data": {
"abiItem": {
"inputs": [],
"name": "ERC20Base__ApproveToZeroAddress",
"type": "error"
},
"errorName": "ERC20Base__ApproveToZeroAddress"
}
}
}
}
Credit
Create an allowance
This is endpoint returns an unsigned transaction that pre-approves a spender_address account to transfer a specified amount of tokens from the holder_address account. Once you sign this transaction, using your private key held in your local environment variables, you can broadcast it using the Execute Transaction endpoint; or if you prefer to wait for confirmation using the Execute Transaction and Wait endpoint.
POST
/
credit
/
approve
cURL
curl --request POST \
--url https://api.openformat.tech/v1/credit/approve \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"chain": "arbitrum-sepolia",
"token_id": "0xd1f09c70f6f2838a3ab6209c1465af68594667ec",
"holder_address": "0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9",
"spender_address": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
"amount": 123
}
'import requests
url = "https://api.openformat.tech/v1/credit/approve"
payload = {
"chain": "arbitrum-sepolia",
"token_id": "0xd1f09c70f6f2838a3ab6209c1465af68594667ec",
"holder_address": "0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9",
"spender_address": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
"amount": 123
}
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
chain: 'arbitrum-sepolia',
token_id: '0xd1f09c70f6f2838a3ab6209c1465af68594667ec',
holder_address: '0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9',
spender_address: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
amount: 123
})
};
fetch('https://api.openformat.tech/v1/credit/approve', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.openformat.tech/v1/credit/approve",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'chain' => 'arbitrum-sepolia',
'token_id' => '0xd1f09c70f6f2838a3ab6209c1465af68594667ec',
'holder_address' => '0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9',
'spender_address' => '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
'amount' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.openformat.tech/v1/credit/approve"
payload := strings.NewReader("{\n \"chain\": \"arbitrum-sepolia\",\n \"token_id\": \"0xd1f09c70f6f2838a3ab6209c1465af68594667ec\",\n \"holder_address\": \"0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9\",\n \"spender_address\": \"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266\",\n \"amount\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.openformat.tech/v1/credit/approve")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"chain\": \"arbitrum-sepolia\",\n \"token_id\": \"0xd1f09c70f6f2838a3ab6209c1465af68594667ec\",\n \"holder_address\": \"0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9\",\n \"spender_address\": \"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266\",\n \"amount\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.openformat.tech/v1/credit/approve")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"chain\": \"arbitrum-sepolia\",\n \"token_id\": \"0xd1f09c70f6f2838a3ab6209c1465af68594667ec\",\n \"holder_address\": \"0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9\",\n \"spender_address\": \"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266\",\n \"amount\": 123\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"unsignedTransaction": {
"to": "0x014b680bed2433b1861239cf812dbe660fe339f2",
"data": "0x609512c90000000000000000000000009574e9ba92cb0966c9d2ff1a9ab9e11949b9b873000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000de0b6b3a7640000647261676f6e5f736c6179656400000000000000000000000000000000000000414354494f4e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000",
"maxPriorityFeePerGas": "1020840008",
"maxFeePerGas": "1035102698",
"gas": "476358",
"gasLimit": "476358",
"nonce": 36,
"chainId": 31337,
"type": 2
}
}
{
"success": false,
"error": {
"code": "validation_error",
"message": "Some parameters are invalid",
"issues": [
{
"code": "too_small",
"message": "Number must be greater than 0",
"parameter": "amount",
"path": "amount"
}
]
}
}
{
"success": false,
"error": {
"code": "token_not_found",
"message": "Credit token not found"
}
}
{
"success": false,
"error": {
"code": "transaction_error",
"message": "There was an error in the blockchain transaction",
"transaction_error": {
"reason": "Error: ERC20Base__ApproveToZeroAddress() ",
"message": "The contract function \"approve\" reverted.",
"detailsMessage": "Error: ERC20Base__ApproveToZeroAddress() Contract Call: address: 0x014b680bed2433b1861239cf812dbe660fe339f2\n function: approve(address spender, uint256 amount)\n args: (0x0000000000000000000000000000000000000000, 1000000000000000000)\n sender: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
"contract_address": "0x014b680bed2433b1861239cf812dbe660fe339f2",
"chain_id": 31337,
"function_name": "approve",
"data": {
"abiItem": {
"inputs": [],
"name": "ERC20Base__ApproveToZeroAddress",
"type": "error"
},
"errorName": "ERC20Base__ApproveToZeroAddress"
}
}
}
}
{
"success": true,
"unsignedTransaction": {
"to": "0x014b680bed2433b1861239cf812dbe660fe339f2",
"data": "0x609512c90000000000000000000000009574e9ba92cb0966c9d2ff1a9ab9e11949b9b873000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000de0b6b3a7640000647261676f6e5f736c6179656400000000000000000000000000000000000000414354494f4e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000",
"maxPriorityFeePerGas": "1020840008",
"maxFeePerGas": "1035102698",
"gas": "476358",
"gasLimit": "476358",
"nonce": 36,
"chainId": 31337,
"type": 2
}
}
{
"success": false,
"error": {
"code": "validation_error",
"message": "Some parameters are invalid",
"issues": [
{
"code": "too_small",
"message": "Number must be greater than 0",
"parameter": "amount",
"path": "amount"
}
]
}
}
{
"success": false,
"error": {
"code": "token_not_found",
"message": "Credit token not found"
}
}
{
"success": false,
"error": {
"code": "transaction_error",
"message": "There was an error in the blockchain transaction",
"transaction_error": {
"reason": "Error: ERC20Base__ApproveToZeroAddress() ",
"message": "The contract function \"approve\" reverted.",
"detailsMessage": "Error: ERC20Base__ApproveToZeroAddress() Contract Call: address: 0x014b680bed2433b1861239cf812dbe660fe339f2\n function: approve(address spender, uint256 amount)\n args: (0x0000000000000000000000000000000000000000, 1000000000000000000)\n sender: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
"contract_address": "0x014b680bed2433b1861239cf812dbe660fe339f2",
"chain_id": 31337,
"function_name": "approve",
"data": {
"abiItem": {
"inputs": [],
"name": "ERC20Base__ApproveToZeroAddress",
"type": "error"
},
"errorName": "ERC20Base__ApproveToZeroAddress"
}
}
}
}
Authorizations
Body
application/json
Blockchain network to use
Required string length:
1 - 255Example:
"arbitrum-sepolia"
Ethereum address of the credit token
Example:
"0xd1f09c70f6f2838a3ab6209c1465af68594667ec"
Ethereum address of the token holder account
Example:
"0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9"
Ethereum address of the spender account
Example:
"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"
Amount of credit tokens to approve
Required range:
x > 0Example:
123
⌘I