LogoLogo
MidpointContact UsThe Docs are Wrong!
  • What is Midpoint
  • What actually is a midpoint?
  • Midpoint FAQs
  • Get Started
    • Sample Midpoints
      • Filecoin Filrep Oracle: Obtain miner reputations on-chain
      • Oracle: Call any API from a smart contract
      • Listener: Subscribe an internal service to any event
      • Data Feed: Stream a data feed on-chain at regular intervals
      • Data Bridge: Pass arbitrary messages between chains
      • Automation: Ensure a function is called at regular intervals
    • Videos
  • Using Midpoint
    • API Key
    • Midpoint CLI
    • GraphQL API
    • Dashboard
  • Core Concepts
    • Midpoints
      • Midpoint ID
      • Sources
      • Tasks
      • Source and Task Definitions
        • Secrets
        • Variables
        • Exclude Logs
        • Extracts
    • Requests
      • Request ID
      • Events
    • Credits and Payment
  • Sources
    • Startpoint Called
    • EVM Event Emitted
    • Cron Job Triggered
  • Tasks
    • Make HTTP Request
      • OAuth and Multi-Step Authentication
    • Call EVM Function
    • Transact to EVM Function
      • Security
    • Shift Decimal
  • More Reading
    • Chain IDs
    • Startpoints
    • Midpoint EOAs
  • Get in Touch
    • Contact Links
Powered by GitBook
On this page
  • Using a Startpoint
  • Packing _data
  • Definition
  • Returned Values
  • Examples
  • Tips on Using Startpoint Called

Was this helpful?

  1. Sources

Startpoint Called

Listens for an invocation of a Midpoint-deployed startpoint.

PreviousCredits and PaymentNextEVM Event Emitted

Last updated 2 years ago

Was this helpful?

Triggers when a contract invokes the callMidpoint function on a Midpoint-deployed Startpoint contract.

Startpoint Called is used to trigger a midpoint from on-chain by making a call to the callMidpoint function in a Midpoint-deployed contract. Startpoint Called is used when creating oracles, data bridges, or any other workflow that begins with a contract on chain 'initiating' the workflow.

Using a Startpoint

Every chain has one Startpoint contract with the following two public functions:

interface IMidpoint {
    function callMidpoint(uint64 midpointId) external returns(uint64 requestId);
    function callMidpoint(uint64 midpointId, bytes calldata _data) external returns(uint64 requestId);
}

A Startpoint is triggered by invoking a call to the callMidpoint function and passing the and optionally passing in a packed byte array _data. The startpoint contract will assign and return a globall unique to the caller. This can be used to associate a response transaction with the originating call.

Startpoints currently support intN, uintN, boolean, address, and string Solidity types.

Packing _data

The Startpoint contract expects all of the passed parameters (defined in variables) to be packed according to the following specification.

  1. Parameters are packed with Solidity's abi.encodePacked().

  2. Parameters are ordered according to the order defined in the StartpointCalledSource definition.

  3. Each string is followed by a Null byte, indicated with bytes1(0x00)

  4. No additional values are added to _data

Examples:

  • A StartpointCalledSource is expecting a single int256 valued called X.

IMidpoint(startpointAddress).callMidpoint(midpointID, abi.encodePacked(X));
  • A StartpointCalledSource is expecting two string values called Y and Z.

bytes args = abi.encodePacked(Y, bytes1(0x00), Z, bytes1(0x00));
IMidpoint(startpointAddress).callMidpoint(midpointID, args);
  • A StartpointCalledSource is expecting three variables in the following order: a uint256 called A, a string called B and a boolean called C.

bytes args = abi.encodePacked(A, B, bytes1(0x00), C);
IMidpoint(startpointAddress).callMidpoint(midpointID, args);
  • A StartpointCalledSource is expecting no variables.

IMidpoint(startpointAddress).callMidpoint(midpointID);

Definition

whitelist:[ 
  {
    chainId: string
    contractAddress: string
  }
]
variables:[ 
  {
    name: string
    datatype: string
  }
]
extracts: [
  {
    name: string
    from: string
  }
]
excludeLogs: [string]

whitelist: Array of {string, string}. Array of chainId - contractAddress pairs. The Startpoint only listens for invocations to callMidpoint that come from a whitelisted chainId and contractAddress pair. A single Startpoint Called source may listen for calls from multiple contracts and chains simultaneously.

whitelist.contractAdddress: Ethereum Address. A valid 40-character Ethereum address prepended with 0x. Example: 0xEf1c6E67703c7BD7107eed8303Fbe6EC2554BF6B

variables: Array of {string, string}. Ordered array of variables that are expected to be passed from on-chain when this midpoint is called.

variables.name: String.The name to be assigned to this variable for use in future tasks.

variables.datatype: Enum[uintN, intN, boolean, string, address]. The Solidity type expected to be passed from on-chain. example: uint256

  • Timestamp Unixtime of execution.

  • Contract_Address The contract address that invoked the call to the Startpoint.

  • Chain_ID The chain ID where the Startpoint was called.

  • Block_Number The block number containing the transaction making the call.

  • Txn_Hash The transaction hash of the transaction making the call.

  • Txn_Origin The EOA that initiated the transaction that made the call.

  • TaskDefinition The complete definition of this task at runtime.

Returned Values

The Startpoint Called source returns each of the variables listed under the variables field for use in future tasks - in addition to each field specified in extracts.

Examples

This section is incomplete.

Tips on Using Startpoint Called

This section is incomplete.

See for detailed information on the Startpoint contract and deployed startpoing addresses.

whitelist.chainId: See .

extracts: See . Legal values:

Midpoint_ID See .

Request_ID See .

excludeLogs: See . Legal values:

Midpoint ID
Request ID
Startpoints
Chain IDs
extracts
Midpoint ID
Request ID
exclude logs