(Deprecated) Initiate Contract Call

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

Recent Requests
Log in to see full request history
TimeStatusUser Agent
Retrieving recent requests…
LoadingLoading…

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

*/
Body Params
string
required

Your unique application ID

string
required

The Id of the account to call the contract from. Must have permissions = "DEFI"

string
required

The Id of the whitelisted smart contract destination

string
required

An amount to be sent in this function call, denominated in the smallest divisible unit of base asset - wei. Use '0' if you do not want to send an amount.

string
required

The currency to be used for this function call.

string
required

The blockchain network to be used for this function call. The network must be one of ETH or BSC currently.

string

Optional gas price (in wei) for your contract call. If specified, both gasPrice and gasLimit must be set.

string

Optional gasLimit for your contract call. If specified, both gasPrice and gasLimit must be set.

string
required

Hex encoded data string for your function call. See the example in the "Moving Money Around" section for more info.

string
required

The transaction ID related to this DeFi transaction, i.e. the ID of the on-chain transaction that led to funds being available in the "DeFi" account. This is the transaction ID returned by Striga, NOT the transaction hash on the blockchain

string
required

Amount expected to be utilized in this transaction (In smallest divisible currency units)

Headers
string
required

api-key is available on the dashboard

Response

Language
Credentials
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json