➑️Test, Deploy & Run Typescript functions

Testing Typescript Functions

To test your Typescript Function locally, run:

npx hardhat w3f-run W3FNAME


npx hardhat w3f-run oracle

Optional flags:

  • --logs Show internal Web3 Function logs

  • --debug Show Runtime debug messages

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


npx hardhat w3f-run oracle --logs --network hardhat


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 hardhat w3f-deploy W3FNAME


npx hardhat w3f-deploy oracle 

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.

Last updated