Skip to content

Latest commit

 

History

History
30 lines (25 loc) · 1.44 KB

README.md

File metadata and controls

30 lines (25 loc) · 1.44 KB

Web3 Extension for Azure Functions

This extension provides trigger bindings in Microsoft Azure Functions, allowing you to interact with web3-compatible blockchain event frictionlessly, powered by Web3 Provider of Nethereum project. Currently, following trigger is actively developed.

  • BlockTrigger: triggered by ethereum block event.

Usage

BlockTrigger

// Set endpoint URL inline
[FunctionName("Function1")]
public static async Task Run([Web3BlockTrigger("https://mainnet.infura.io/v3/<YOUR_PROJECT_ID>")] BlockWithTransactions block, ILogger log)
{
    log.LogInformation($"Block[{block.Number}, {block.BlockHash}], tx: {block.Transactions.Length}");
}

// Set endpoint from config file
[FunctionName("Function2")]
public static async Task Run([Web3BlockTrigger("%EthereumEndpoint%")] BlockWithTransactions block, ILogger log)
{
    log.LogInformation($"Block[{block.Number}, {block.BlockHash}], tx: {block.Transactions.Length}");
}

// Set required number of blocks to confirm. default to 12 if unset.
[FunctionName("Function3")]
public static async Task Run([Web3BlockTrigger("%EthereumEndpoint%", 30)] BlockWithTransactions block, ILogger log)
{
    log.LogInformation($"Block[{block.Number}, {block.BlockHash}], tx: {block.Transactions.Length}");
}