There are two components to onboarding your stack to using the GMP API:
Access to the GMP API will be permissioned across all environments and requires a certificate to access any of the API endpoints. The API will be using mTLS authentication, so each partner building a chain integration that desires to leverage the GMP API will require certificates issues by us for each integration.
To authenticate, please do the following:
openssl req -new -newkey rsa:4096 -keyout client.key -out client.csr -nodes -subj '/CN=<ChainName>/OU=devnet/O=<PartnerName>'
Where:
subj
need to be in this specific format/OU=devnet
is constant/CN=<ChainName>
- name of the chain your integration will be managing
/CN=...
attributes in the subject if you need access to multiple chains, e.g. -subj '/CN=CHAINA/CN=CHAINB
/O=<PartnerName>
- name of your team, somewhat arbitrary, just so we know who the certificate is for (please avoid weird characters)Once you send us your CSR, we will generate a certificate and send it back to you to use in any of your requests, and any call to any of the API’s endpoints must be secured by that certificate, e.g.
const dotenv = require('dotenv');
const https = require('https');
// Load environment variables from .env file
dotenv.config();
// Load the certificate and key
const cert = fs.readFileSync(process.env.CRT_PATH);
const key = fs.readFileSync(process.env.KEY_PATH);
const gmpAPIURL = process.env.GMP_API_URL;
const httpsAgent = new https.Agent({
cert,
key,
});
// query the task GET endpoint
const latestTask = "01924dc4-698e-7ad2-9f9b-0bad962771ef"; // just an example
let urlSuffix = '';
if (latestTask !== '') {
urlSuffix = `?after=${latestTask}`;
}
const destinationChain = "CHAIN_B";
const url = `${gmpAPIURL}/chains/${destinationChain}/tasks${urlSuffix}`;
console.log('Polling tasks on:', url);
try {
const response = await axios({
method: 'get',
url,
httpsAgent,
});
const tasks = response.data.tasks;
if (tasks.length === 0) {
console.log('No new tasks\\n');
return;
}
for (const task of tasks) {
await processTask(task, chainConfig, intervalId);
}
} catch (error) {
console.error('Error:', error.message);
}
Interop Labs also needs to whitelist the Amplifier contracts for your integration. Simply send us the following addresses for your chain