Gelato
  • Introduction
    • Gelato, The Web3 Cloud Platform
  • Smart Wallets
    • Introduction
      • Understanding EIP-7702
      • Understanding ERC-4337
      • ERC-4337 vs EIP-7702
    • Templates & Examples
    • How-To Guides
      • Create a Sponsor API Key
      • Sponsor gas for your users
      • Allow users to pay gas with erc20
      • Allow users to pay gas with native
      • Create Dynamic's Environment Id
      • Use Dynamic/Privy signers with React SDK
      • Estimate Gas for your transactions
    • React SDK
    • Demo
    • Supported Networks
  • Rollup As A Service
    • Introduction
    • Rollup Stacks
      • Arbitrum Orbit
        • Run a Full Orbit Node
      • OP Stack
        • Run OP Node
    • Deploy your Rollup
    • Customization
      • Data Availability
        • Celestia
        • Avail
        • Eigen DA
      • Custom Gas Token
      • Marketplace
        • Gelato Services
        • Data Indexers
        • Block Explorers
        • Oracles
        • Bridges
        • Account Abstraction
        • On & Off-ramp
        • Community
        • Identity & KYC
        • Others
      • Verifier Node Package
    • Public Testnet
  • RPC Nodes
    • Introduction
    • Compute Units
    • Using RPC Nodes
    • Supported Networks
    • Pricing and Plans
    • FAQ
  • Web3 Services
    • Web3 Functions
      • Understanding Web3 Functions
        • Trigger Types
        • Typescript Function
        • Solidity Function
        • Automated Transactions
      • Security Considerations
      • Template & Use Cases
      • Quick Start
        • Writing Typescript Functions
          • Event Trigger
          • Private Typescript Functions
          • Callbacks
        • Test, Deploy & Run Typescript functions
        • Writing Solidity Functions
        • Test, Deploy & Run Solidity Functions
        • Initiate an Automated Transaction
      • Create a Web3 Function Task
        • Using the UI
        • Using the Safe App
        • Using a Smart Contract
        • Using the Automate SDK
      • Analytics & Monitoring
      • Supported Networks
      • Subscription & Payments
      • Legacy Automate Migration Guide
    • Relay
      • What is Relaying?
      • Security Considerations
        • ERC-2771 Delegatecall Vulnerability
      • Templates
      • Quick Start
        • Sponsored Calls
        • Non-Sponsored Calls
      • ERC-2771 (recommended)
        • SponsoredCallERC2771
        • CallWithSyncFeeERC2771
          • Relay Context Contracts ERC2771
      • Non-ERC-2771
        • SponsoredCall
        • CallWithSyncFee
          • Relay Context Contracts
      • Relay API
      • Gelato's Fee Oracle
      • Tracking your Relay Request
      • Supported Networks
      • Subscriptions and Payments
        • 1Balance & Relay
        • SyncFee Payment Tokens
        • Relay Pricing
      • ERC2771 Migration Guide
    • VRF
      • Understanding VRF
      • How does Gelato VRF Work?
      • Security Considerations
      • Template
      • Quick Start
      • Create a VRF Task
        • Create a Fallback VRF
        • Migrating from Chainlink VRF
      • Supported Networks
      • Pricing & Rate Limits
    • Oracles
      • Understanding Gelato Oracles
      • Quick Start
      • Data Providers
        • Stork
        • Choas Labs
      • Migrating from Chainlink Oracles
      • Available Price Feeds
      • Supported Networks
      • Pricing & Rate Limits
    • Account Abstraction
      • Understanding ERC-4337
      • Introduction to Gelato Bundler
      • Templates & Examples
      • Quick Start
      • Supported Networks
      • Bundler API Endpoints
        • eth_sendUserOperation
        • eth_estimateUserOperationGas
        • eth_getUserOperationByHash
        • eth_getUserOperationReceipt
        • eth_supportedEntryPoints
        • eth_maxPriorityFeePerGas
        • eth_chainId
    • 1Balance
      • 1Balance Alerts
      • Subscription Plans
      • Subscription Notifications
      • USDC Addresses
    • AI Agents
    • Teams
  • GELATO DAO
    • DAO & Token (GEL)
    • GEL Token Contracts
    • Governance Process
  • Social Media
Powered by GitBook
On this page
  • Testing Typescript Functions
  • Optional flags:
  • Deploying Typescript Functions
  • Creating Typescript Function Task
  1. Web3 Services
  2. Web3 Functions
  3. Quick Start

Test, Deploy & Run Typescript functions

Testing Typescript Functions

To test your Typescript Function locally, run:

npx w3f test path/to/web3-functions/index.ts --logs

or

npx hardhat w3f-run W3FNAME --logs

Example:

npx w3f test oracle/index.ts --logs

Optional flags:

  • --logs Show internal Web3 Function logs

  • --debug Show Runtime debug messages

  • --chain-id [NETWORK] Set the default runtime network & provider.

Example:

npx w3f test path/to/web3-functions/index.ts --logs --chain-id=<chain id>

or

npx hardhat wrf-run web3-function --logs --network hardhat

Output:

Web3Function Build result:
 ✓ Schema: /Users/chuahsonglin/Documents/GitHub/Gelato/contract/w3f-template/web3-functions/oracle/schema.json
 ✓ Built file: /Users/chuahsonglin/Documents/GitHub/Gelato/contract/w3f-template/.tmp/index.js
 ✓ File size: 2.47mb
 ✓ Build time: 947.91ms

Web3Function user args validation:
 ✓ currency: ethereum
 ✓ oracle: 0x71B9B0F6C999CBbB0FeF9c92B80D54e4973214da

Web3Function running logs:
> Last oracle update: 0
> Next oracle update: 3600
> Updating price: 1898

Web3Function Result:
 ✓ Return value: {
  canExec: true,
  callData: [
    {
      to: '0x71B9B0F6C999CBbB0FeF9c92B80D54e4973214da',
      data: '0x8d6cc56d000000000000000000000000000000000000000000000000000000000000076a'
    }
  ]
}

Web3Function Runtime stats:
 ✓ Duration: 1.35s
 ✓ Memory: 113.55mb
 ✓ Storage: 0.03kb
 ✓ Rpc calls: 3

Deploying Typescript Functions

To compile your Typescript Function and deploy it to IPFS, use

npx w3f deploy path/to/web3-functions/index.ts --chain-id=<chain-id>

or

npx hardhat w3f-deploy W3FNAME --network sepolia

Example:

npx w3f deploy oracle/index.ts --chain-id=11155111

Once uploaded, Gelato Nodes will pin the file on your behalf on IPFS. If the upload was successful, you should get the IPFS CID of your Typescript Function returned.

 ✓ Web3Function deployed to ipfs.
 ✓ CID: QmbQJC5XGpQUsAkLq6BqpvLtD8EPNDEaPqyFf4xK3TM6xj

Note: This CID will be different for every new Typescript Function version that you will deploy.

Creating Typescript Function Task

Before creating solidity function tasks, familiarize yourself with the available Trigger Types!

  1. Selection of Function

    • Navigate to the What to trigger section.

    • Within the Typescript Function subsection, find the IPFS CID input box.

  2. Function Details Input

    • Input the CID you secured after deploying your Typescript function. Upon entry, you should see a message like "Typescript Function code imported," signifying a successful connection.

  3. Network Configuration

    • Scroll to the Network dropdown menu.

    • Choose the blockchain network where the Typescript function should work, e.g., "Göerli."

  4. Task Configuration

    • If your Typescript function needs secret variables or API keys, securely enter them in the Task Secrets section. For every secret:

      • Key: Define the name of the variable or key, e.g., "API_KEY".

      • Value: Enter the associated secret value.

      • Click Save after each input to guarantee its safe storage.

PreviousCallbacksNextWriting Solidity Functions

Last updated 1 month ago