Invoke Lambda

After the lambda is created from the /v2/app/lambda/create API call or imported using the /v2/app/lambda/import API, use this API to execute a lambda(smart contract) function.

Here are some sample requests:

{
  "lambda": "0x94f943354dB6710da3010bA4F9646402DEC1C73c",
  "function": {
    "name": "mint",
    "args": [
      "123"
    ]
  },
  "reason": "mint an NFT"
}
{
  "lambda": "0x94f943354dB6710da3010bA4F9646402DEC1C73c",
  "function": {
    "name": "mint",
    "args": [
      "123"
    ]
  },
  "as": {
    "email": "[email protected]"
  },
  "reason": "mint an NFT"
}
{
  "lambda": "0x94f943354dB6710da3010bA4F9646402DEC1C73c",
  "function": {
    "name": "mint",
    "args": [
      "123"
    ]
  },
  "pay": "0.3",
  "as": {
    "email": "[email protected]"
  },
  "reason": "mint an NFT"
}

Invoking without as user

If you don't provide an as user in the request body, lambda will be invoked from your developer account and a transaction will be raised and submitted to the Queue on the blockchain. MetaKeep, behind the scenes, employs several strategies to make sure transactions succeed, and at the lowest cost.

You can get the status of this blockchain transaction by querying for transaction status by copying the transactionId from this API response and querying it in Transaction Status API.

❗️

Replaying this API

Once you get a status response as QUEUED, replaying this API doesn't give you the latest status; Replaying the same API with the same Idempotency-Key results in the same response, always with status-QUEUED. You must query the Transaction Status API for the latest status.

As you would learn from the Transaction Status API docs, if a transaction failed, MetaKeep would have exhausted all feasible smart AI-based strategies to recover from failure, that would have been attempted by humans, and the "FAILED" status, if shown, is final.

Invoking with as user

If you provide an as user in the request body, you will get a consentToken back and you will have to use Get Consent flow to finish the lambda invocation. Here, the developer is agreeing to pick up the gas fee on execution so that the user doesn't have to know/understand the concept of gas. MetaKeep, behind the scenes, employs several strategies to make sure transactions succeed, and at the lowest cost.

{
  "status": "USER_CONSENT_NEEDED",
  "consentToken": "CrgBAQIDAHgtrXLM7Takfd-ccn6FAthYppUrIuoEMsncIpxm4af4uUh4Cikr2YkEzasNQr9433Z-V73Hw=="
}

Payment (aka Value Transfer)

You can send an optional payment(value) to a payable lambda function using the pay parameter. This is useful if you want to pay the lambda function for performing some operation. For example, if you want to pay the lambda function for minting an NFT, you can use the pay parameter to send the payment to the lambda function.

📘

Note that the payment is only supported when using BUSINESS_WALLET

Error Status

🚧

Api Error Status

You can find error status returned by the api here.

© Copyright 2024, Passbird Research Inc.

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