Skip to main content
Using near.view and near.call works well for quick scripts, but they are “stringly typed.” If you misspell a method name or pass the wrong arguments, you won’t know until your code crashes at runtime. near-kit allows you to define a TypeScript interface for your contract. This gives you:
  1. Autocomplete for method names.
  2. Type Checking for arguments and return values.
  3. Inline Documentation (if you add JSDoc comments).

1. Define the Interface

You define a type that passes a generic object to Contract. This object must have view and call properties describing your methods.

2. Create the Proxy

Use the near.contract<T>() method to create a typed proxy for a specific contract ID.

3. Use it!

You can now access methods directly under .view and .call.

Calling Views

Arguments are passed as the first parameter.

Calling Change Methods

Change methods take two arguments:
  1. Args: The arguments for the contract function.
  2. Options: (Optional) Gas and Attached Deposit.