Changelog

(Deprecated) Initiate Contract Call

Call a Smart Contract function - Your application must be "DeFi" enabled to use this feature.

DeFi Transactions

If your account is "DeFi" enabled, a separate set of DeFi enabled accounts on ETH and BSC are created for your corporate, which are used for the sole purpose of interacting with smart contracts on their respective chains. These accounts are managed entirely by your application logic and cannot be used for inter, intra or swap transactions.

📘

Using "DeFi" Accounts

These accounts are provisioned as "Corporate" accounts, meaning the sourceAccountId parameter in DeFi contract calls are those of the "DeFi" accounts provisioned for your corporate. These accounts are meant to be utilized in a manner where you collect crypto from your end users by means of a regular on-chain withdrawal (/initate/onchain) into your DeFi account from where you utilize these funds for a smart contract function call such as a swap.

In order to stay compliant, the API takes in a parameter called the relatedTransactionId which refers to the transaction ID that you received when initiating the on-chain withdrawal from your user into the "DeFi" account and an approveAmount indicating the amount of funds that the contract call is to be approved for.

The /contract API with the data of the contract you want to interact with are used as parameters to this API to execute a smart contract function call. This API takes in a whitelistedAddressId parameter, which refers to the address ID returned when a contract address is whitelisted as a corporate. Only your application as a corporate is allowed to use DeFi accounts and therefore contracts that you want to interact with must be whitelisted by you as a corporate.

For example, a "Hello World" contract deployed on the Ethereum Goerli Test Network at 0x93CD6a01A55805A3af582893f2D04051ea47f61D is used with this API as follows -

const ethers = require('ethers');

const CHAIN = 'goerli';
const CONTRACT_ADDRESS = '0x93CD6a01A55805A3af582893f2D04051ea47f61D';
const CONTRACT_ABI = [
  {
    inputs: [],
    name: 'getGreeting',
    outputs: [{ internalType: 'string', name: '', type: 'string' }],
    stateMutability: 'view',
    type: 'function',
  },
  {
    inputs: [{ internalType: 'string', name: '_greeting', type: 'string' }],
    name: 'greet',
    outputs: [],
    stateMutability: 'nonpayable',
    type: 'function',
  },
];

const GREETING = 'Hello from Striga!';

(async function createContractCallData() {
  const contract = new ethers.Contract(
    CONTRACT_ADDRESS,
    CONTRACT_ABI,
    ethers.getDefaultProvider(CHAIN)
  );
  const tx = await contract.populateTransaction.greet(GREETING);

  console.log(tx);
})().catch((err) => {
  console.error(err);
  process.exit(1);
});

/*

The above snippet uses the "ethers" library to generate the contract call data
that is used to interact with the Striga API. Such as: 

{
  data: '0xead710c40000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000d48656c6c6f205374726967612100000000000000000000000000000000000000',
  to: '0x93CD6a01A55805A3af582893f2D04051ea47f61D'
}

The "to" parameter above must be whitelisted via the /corporate/whitelist-address API endpoint
prior to interacting with the /contract endpoint

*/

Language
Authorization
Click Try It! to start a request and see the response here!