CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/npm-web3-eth

Web3 module to interact with the Ethereum blockchain and smart contracts.

Agent Success

Agent success rate when using this tile

67%

Improvement

Agent success rate improvement when using this tile compared to baseline

0.99x

Baseline

Agent success rate without this tile

68%

Overview
Eval results
Files

task.mdevals/scenario-8/

Provider Context Utility

Build a small module that constructs and manages an Ethereum RPC context, letting callers start from either an endpoint string or a provider object. The context should own default block/format settings and expose both instance methods and standalone helpers that all reuse the same underlying provider.

Capabilities

Initialize from endpoint string

  • Creating a context from an HTTPS endpoint string resolves currentBlockHeight() to 12 when the mocked node reports block 12 and the default return format is "number". @test

Initialize from provider object with defaults

  • Given a provider object and defaults { defaultBlock: "pending", returnFormat: "hex" }, calling accountBalance() returns the mocked pending balance "0xde0b6b3a7640000" (1 ether in wei). @test

Share one context across helpers

  • Calling currentBlockHeight() on the context and rpcHelpers().blockHeight() should reuse the same underlying provider (a call counter reaches 2) and produce identical values when the provider increments responses per call. @test

Update defaults at runtime

  • After creating a context with number return format, calling setDefaults({ returnFormat: "hex" }) causes subsequent chainIdentifier() calls to return the mocked hex chain id "0x1" without recreating the provider. @test

Implementation

@generates

API

export interface ProviderDefaults {
  defaultBlock?: "latest" | "pending" | "earliest" | number | string;
  returnFormat?: "number" | "hex";
}

export type RpcProvider = string | { send(method: string, params?: unknown[]): Promise<unknown> };

export interface ProviderContext {
  currentBlockHeight(): Promise<string | number>;
  accountBalance(address: string): Promise<string | number>;
  chainIdentifier(): Promise<string | number>;
  minerAddress(): Promise<string>;
  setDefaults(defaults: ProviderDefaults): void;
  rpcHelpers(): {
    blockHeight(): Promise<string | number>;
    chainIdentifier(): Promise<string | number>;
    minerAddress(): Promise<string>;
  };
}

export function createProviderContext(provider: RpcProvider, defaults?: ProviderDefaults): ProviderContext;

Dependencies { .dependencies }

web3-eth { .dependency }

Ethereum RPC client with configurable provider contexts and return formatting.

tessl i tessl/npm-web3-eth@4.8.0

tile.json