# @aut-labs/abi-types

> ABI Contract functions

Latest version **0.0.89-dev** (published 2024-12-09) · ISC license · 0 weekly downloads

## Install

```sh
npm install @aut-labs/abi-types
pnpm add @aut-labs/abi-types
yarn add @aut-labs/abi-types
bun add @aut-labs/abi-types
```

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.89-dev |
| Published | 2024-12-09 |
| First published | 2023-07-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 826.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Aut |
| Maintainers | jabyl, taulant_disha, migrenaa, antant |

## Links

- npm: https://www.npmjs.com/package/@aut-labs/abi-types
- Repository: https://github.com/Aut-Labs/abi-types
- Homepage: https://github.com/Aut-Labs/abi-types#readme
- Issues: https://github.com/Aut-Labs/abi-types/issues
- npm.io page: https://npm.io/package/@aut-labs/abi-types

## Recent versions

- 0.0.89-dev (latest) — 2024-12-09
- 0.0.88-dev — 2024-12-09
- 0.0.87-dev — 2024-12-01
- 0.0.86-dev — 2024-10-28
- 0.0.85-dev — 2024-10-28
- 0.0.84-dev — 2024-10-19
- 0.0.83-dev — 2024-10-02
- 0.0.82-dev — 2024-10-02
- 0.0.81-dev — 2024-09-21
- 0.0.80-dev — 2024-09-18
- 0.0.79-dev — 2024-09-14
- 0.0.78-dev — 2024-09-14
- 0.0.77-dev — 2024-07-10
- 0.0.76-dev — 2024-07-03
- 0.0.75-dev — 2024-02-29
- … 37 more at https://npm.io/package/@aut-labs/abi-types/versions

## README

# Getting Started with Aut ABI types & Contract proxy

A library which generates typescript types based on abis.

By providing an ExampleContract.abi.ts inside abis folder & running npm build it will:

- Create a folder in the ProviderFactory
- Generate aut-contract-functions.ts which includes all functions & emit events definitions in [ExampleContractFunctions & ExampleContractEventType]
- Generate index.ts which exports the provider as follows:

```ts
const Web3ExampleContractProvider = async (
  addressOrName: string,
  extras?: Partial<Web3ProviderExtras<ExampleContractEventType>>
) => {
  return Web3ContractProvider<ExampleContractEventType, ExampleContractFunctions>(
    addressOrName,
    ExampleABI,
    extras as Web3ProviderExtras<ExampleContractEventType>
  );
};

export { Web3ExampleContractProvider, ExampleContractEventType, ExampleContractFunctions };
```

... additionally there is a Contract Proxy which based on the type provided as seen in the Web3ExampleContractProvider it will provide code completion defined in the ExampleContractFunctions

It also waits for event transactions for example:

```ts
const contract = await Web3ExampleContractProvider(address, {
    event: ExampleContractEventType.SomeEvent
});
```

if the event provide matches the events returned in the transaction the it will **await tx.wait()** as well

This way we reduce a lot boilerplate code.

## How to use

### Generate types

```cmd
npm run build
```

### Install dependency

```cmd
npm install @aut-labs-private/abi-types
```

Example executing transaction with event

```ts
import { ExampleContractEventType, Web3ExampleContractProvider } from "@aut-labs-private/abi-types";

const address = 0x00000...;
(async () => {
  const contract = await Web3ExampleContractProvider(address, {
    event: ExampleContractEventType.SomeEvent,
  });
  try {
    await contract.someFunction();
  } catch (error) {
    console.log(error);
  }
})();
```

Example executing transaction without event

```ts
import { Web3AutIDProvider } from "@aut-labs-private/abi-types";

const address = 0x00000...;
(async () => {
  const contract = await Web3ExampleContractProvider(address);
  try {
    await contract.someFunction();
  } catch (error) {
    console.log(error);
  }
})();
```

## Extras

### Provider Config Parameters

```ts
export interface Web3ProviderExtras<EventTypes> {
  event: EventTypes;
  signer: () => Promise<ethers.providers.JsonRpcSigner>;
  provider: () => Promise<ethers.providers.Web3Provider>;
  beforeRequest: Function;
  afterRequest: Function;
  transactionState: (
    state: "started" | "rejected" | "waiting" | "done",
    ...args: any
  ) => void;
}
```

**NOTE** - By default it creates a provider from ethers.js which will deprectated and removed in the future

```ts
const provider = new ethers.providers.Web3Provider(window.ethereum);
```

Its recommended that you provide your own signer as follows:

```ts
import { ExampleContractEventType, Web3ExampleContractProvider } from "@aut-labs-private/abi-types";
import { ethers } from "ethers";

const address = 0x00000...;
(async () => {
  const provider = new ethers.providers.Web3Provider(window.ethereum);
  const signer = provider.getSigner();
  const contract = await Web3ExampleContractProvider(address, {
    event: ExampleContractEventType.SomeEvent,
    signer: async () => signer
  });
  try {
    await contract.someFunction();
  } catch (error) {
    console.log(error);
  }
})();
```


## Available Web3 Providers

- Web3AutIDProvider
- Web3CommunityCallProvider
- Web3DAOExpanderFactoryProvider
- Web3DAOExpanderProvider
- Web3DAOExpanderRegistryProvider
- Web3InteractionsProvider
- Web3ManifestoProvider
- Web3PollsProvider
- Web3TasksProvider

---
_Source: https://npm.io/package/@aut-labs/abi-types · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
