Deploy a Contract
To interact with a smart contract through FSCO, you’ll first need to deploy it by uploading the contract ABI and registering the deployment. This guide walks you through that two-step process.
Prerequisites
Section titled “Prerequisites”Before you begin, ensure you have:
- A valid FSCO API key
- Your compiled contract’s ABI (JSON)
- The contract already deployed on-chain
Step 1: Upload the ABI
Section titled “Step 1: Upload the ABI”Endpoint
Section titled “Endpoint”POST /v2/contract/abi
Request Body
Section titled “Request Body”{ "name": "MyContract", "abi": [/* ... ABI JSON ... */], "interfaceTypes": ["ERC20"], "isShared": true}
The request requires:
name
: The name of the contractabi
: The ABI of the contractinterfaceTypes
: The types of interfaces the contract implementsisShared
: Whether this ABI should be available across environments
Example Request
Section titled “Example Request”curl -X POST https://api.fsco.io/v2/contract/abi \ -H "Authorization: Bearer $FSCO_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "MyContract", "abi": [ { "type": "function", "name": "balanceOf", "inputs": [ { "name": "account", "type": "address" } ], "outputs": [ { "name": "", "type": "uint256" } ], "stateMutability": "view" } ], "interfaceTypes": ["ERC20"], "isShared": true }'
import axios from 'axios';
const FSCO_API_KEY = process.env.FSCO_API_KEY;
const uploadAbi = async () => { const response = await axios.post( 'https://api.fsco.io/v2/contract/abi', { name: 'MyContract', abi: [ { type: 'function', name: 'balanceOf', inputs: [ { name: 'account', type: 'address' } ], outputs: [ { name: '', type: 'uint256' } ], stateMutability: 'view' } ], interfaceTypes: ['ERC20'], isShared: true }, { headers: { Authorization: `Bearer ${FSCO_API_KEY}`, 'Content-Type': 'application/json' } } );
console.log('ABI uploaded:', response.data);};
uploadAbi();
import requestsimport os
FSCO_API_KEY = os.getenv("FSCO_API_KEY")
headers = { "Authorization": f"Bearer {FSCO_API_KEY}", "Content-Type": "application/json",}
payload = { "name": "MyContract", "abi": [ { "type": "function", "name": "balanceOf", "inputs": [{"name": "account", "type": "address"}], "outputs": [{"name": "", "type": "uint256"}], "stateMutability": "view", } ], "interfaceTypes": ["ERC20"], "isShared": True,}
response = requests.post( "https://api.fsco.io/v2/contract/abi", json=payload, headers=headers)
print("ABI uploaded:", response.json())
using System;using System.Net.Http;using System.Net.Http.Headers;using System.Text;using System.Threading.Tasks;
class Program{ static async Task Main() { var apiKey = Environment.GetEnvironmentVariable("FSCO_API_KEY");
var client = new HttpClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
var json = @"{ ""name"": ""MyContract"", ""abi"": [ { ""type"": ""function"", ""name"": ""balanceOf"", ""inputs"": [ { ""name"": ""account"", ""type"": ""address"" } ], ""outputs"": [ { ""name"": """", ""type"": ""uint256"" } ], ""stateMutability"": ""view"" } ], ""interfaceTypes"": [""ERC20""], ""isShared"": true }"; var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.fsco.io/v2/contract/abi", content); var responseString = await response.Content.ReadAsStringAsync();
Console.WriteLine("ABI uploaded: " + responseString); }}
Response
Section titled “Response”{ "queryId": "{{queryId UUID string}}"}
Step 2: Register the Deployment
Section titled “Step 2: Register the Deployment”Endpoint
Section titled “Endpoint”POST /v2/contract/deployment
{ "name": "MyContractDeployment", "chainId": "13337", "contractAddress": "0xabc123...", "abiId": "your-uploaded-abi-id", "isShared": true}
The request requires:
name
: Name for this specific deploymentchainId
: The actual chainId of the EVM chain the contract is deployed tocontractAddress
: The address the contract is deployed toabiId
: The ID from the upload stepisShared
: Whether to make this available across environments
Example Request
Section titled “Example Request”curl -X POST https://api.fsco.io/v2/contract/deployment \ -H "Authorization: Bearer $FSCO_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "referenceId": "MyContractDeployment", "chainId": "13337", "contractAddress": "0xabc123456789abcdef123456789abcdef1234567", "abiId": "123e4567-e89b-12d3-a456-426614174000", "isShared": true }'
import axios from 'axios';
const FSCO_API_KEY = process.env.FSCO_API_KEY;const registerDeployment = async () => { const response = await axios.post( 'https://api.fsco.io/v2/contract/deployment', { referenceId: 'MyContractDeployment', chainId: '13337', contractAddress: '0xabc123456789abcdef123456789abcdef1234567', abiId: '123e4567-e89b-12d3-a456-426614174000', isShared: true, }, { headers: { Authorization: `Bearer ${FSCO_API_KEY}`, 'Content-Type': 'application/json', }, } );
console.log('Contract deployment registered:', response.data);};
registerDeployment();
import requestsimport os
FSCO_API_KEY = os.getenv("FSCO_API_KEY")
headers = { "Authorization": f"Bearer {FSCO_API_KEY}", "Content-Type": "application/json",}
payload = { "referenceId": "MyContractDeployment", "chainId": "13337", "contractAddress": "0xabc123456789abcdef123456789abcdef1234567", "abiId": "123e4567-e89b-12d3-a456-426614174000", "isShared": True,}
response = requests.post( "https://api.fsco.io/v2/contract/deployment", json=payload, headers=headers)
print("Contract deployment registered:", response.json())
using System;using System.Net.Http;using System.Net.Http.Headers;using System.Text;using System.Threading.Tasks;
class ContractDeploymentRegistration{ static async Task Main() { var apiKey = Environment.GetEnvironmentVariable("FSCO_API_KEY");
var client = new HttpClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
var json = @"{ ""referenceId"": ""MyContractDeployment"", ""chainId"": ""13337"", ""contractAddress"": ""0xabc123456789abcdef123456789abcdef1234567"", ""abiId"": ""123e4567-e89b-12d3-a456-426614174000"", ""isShared"": true }"; var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.fsco.io/v2/contract/deployment", content); var responseString = await response.Content.ReadAsStringAsync();
Console.WriteLine("Contract deployment registered: " + responseString); }}
Important Notes
Section titled “Important Notes”- Both ABI and Deployment must be registered before calling or querying methods
- Use meaningful names so you can easily find and reuse these resources later
- Shared ABIs and deployments are visible across environments (e.g. staging, production)