# @andex/provider

> Web3-like interface for the Venom blockchain

Latest version **1.0.0** (published 2023-06-07) · GPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install @andex/provider
pnpm add @andex/provider
yarn add @andex/provider
bun add @andex/provider
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2023-06-07 |
| First published | 2023-06-07 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 222 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | natedotv2 |

## Links

- npm: https://www.npmjs.com/package/@andex/provider
- Repository: https://github.com/andex-fi/andex-provider
- Homepage: https://github.com/andex-fi/andex-provider#readme
- Issues: https://github.com/andex-fi/andex-provider/issues
- npm.io page: https://npm.io/package/@andex/provider

## Recent versions

- 1.0.0 (latest) — 2023-06-07

## README

# Venom inpage provider &emsp;  [![Latest Version]][npmjs.com] [![Docs badge]][docs]

## About

Web3-like interface to the Venom blockchain.

## Usage

### How to install

```shell
yarn add --save @andex/provider
```

> NOTE: this repo was inspired `everscale-inpage-provider` package which is not tailored for Venom specifically.

### Contents

- [`src/api.ts`](./src/api.ts) - RPC interface description
- [`src/models.ts`](./src/models.ts) - general models, used in RPC interface
- [`src/contract.ts`](./src/contract.ts) - typed contracts wrapper
- [`src/stream.ts`](./src/stream.ts) - user-friendly api for streams
- [`src/utils.ts`](./src/utils.ts) - some useful stuff

### Example

```typescript
import {
  Address,
  ProviderRpcClient,
  TvmException
} from '@andex/provider';

const venom = new ProviderRpcClient();

async function myApp() {
  if (!(await venom.hasProvider())) {
    throw new Error('Extension is not installed');
  }

  const { accountInteraction } = await venom.requestPermissions({
    permissions: ['basic', 'accountInteraction'],
  });
  if (accountInteraction == null) {
    throw new Error('Insufficient permissions');
  }

  const selectedAddress = accountInteraction.address;
  const dePoolAddress = new Address('0:bbcbf7eb4b6f1203ba2d4ff5375de30a5408a8130bf79f870efbcfd49ec164e9');

  const dePool = new venom.Contract(DePoolAbi, dePoolAddress);

  const transaction = await dePool
    .methods
    .addOrdinaryStake({
      stake: '10000000000',
    }).send({
      from: selectedAddress,
      amount: '10500000000',
      bounce: true,
    });
  console.log(transaction);

  try {
    const output = await dePool
      .methods
      .getParticipantInfo({
        addr: selectedAddress,
      })
      .call();
    console.log(output);
  } catch (e) {
    if (e instanceof TvmException) {
      console.error(e.code);
    }
  }
}

const DePoolAbi = {
  'ABI version': 2,
  'header': ['time', 'expire'],
  'functions': [{
    'name': 'addOrdinaryStake',
    'inputs': [
      { 'name': 'stake', 'type': 'uint64' },
    ],
    'outputs': [],
  }, {
    'name': 'getParticipantInfo',
    'inputs': [
      { 'name': 'addr', 'type': 'address' },
    ],
    'outputs': [
      { 'name': 'total', 'type': 'uint64' },
      { 'name': 'withdrawValue', 'type': 'uint64' },
      { 'name': 'reinvest', 'type': 'bool' },
      { 'name': 'reward', 'type': 'uint64' },
      { 'name': 'stakes', 'type': 'map(uint64,uint64)' },
      {
        'components': [
          { 'name': 'remainingAmount', 'type': 'uint64' },
          { 'name': 'lastWithdrawalTime', 'type': 'uint64' },
          { 'name': 'withdrawalPeriod', 'type': 'uint32' },
          { 'name': 'withdrawalValue', 'type': 'uint64' },
          { 'name': 'owner', 'type': 'address',
        }],
        'name': 'vestings', 'type': 'map(uint64,tuple)',
      },
      {
        'components': [
          { 'name': 'remainingAmount', 'type': 'uint64' },
          { 'name': 'lastWithdrawalTime', 'type': 'uint64' },
          { 'name': 'withdrawalPeriod', 'type': 'uint32' },
          { 'name': 'withdrawalValue', 'type': 'uint64' },
          { 'name': 'owner', 'type': 'address',
        }],
        'name': 'locks', 'type': 'map(uint64,tuple)',
      },
      { 'name': 'vestingDonor', 'type': 'address' },
      { 'name': 'lockDonor', 'type': 'address' },
    ],
  }],
  'data': [],
  'events': [],
} as const; // NOTE: `as const` is very important here

myApp().catch(console.error);
```

### Build

```shell
npm install

# Build as ts library
# (output will be in the `dist` folder)
npm run build

# Build as js library to use directly in <script> tags
# (output will be in the `vanilla` folder)
npm run build:vanilla
```

## Contributing

We welcome contributions to the project! If you notice any issues or errors, feel free to open an issue or submit a pull request.

## License

Licensed under GPL-3.0 license ([LICENSE](/LICENSE) or https://opensource.org/license/gpl-3-0/).

[latest version]: https://img.shields.io/npm/v/@andex/provider
[npmjs.com]: https://www.npmjs.com/package/@andex/provider
[docs badge]: https://img.shields.io/badge/docs-latest-brightgreen
[docs]: https://andex-fi.github.io/andex-provider/index.html

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