0.3.64 • Published 4 months ago

everscale-inpage-provider v0.3.64

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
4 months ago

Everscale inpage provider Latest Version Docs badge

About

Web3-like interface to the Everscale blockchain.

Usage

How to install

npm install --save everscale-inpage-provider

NOTE: this repo was originally used for ton-inpage-provider package which is DEPRECATED now.

Contents

Example

import {
  Address,
  ProviderRpcClient,
  TvmException
} from 'everscale-inpage-provider';

const ever = new ProviderRpcClient();

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

  const { accountInteraction } = await ever.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 ever.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

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 or https://opensource.org/license/gpl-3-0/).

0.3.64

4 months ago

0.3.63

7 months ago

0.3.62

8 months ago

0.3.61

12 months ago

0.3.60

12 months ago

0.3.59

12 months ago

0.3.58

1 year ago

0.3.53

1 year ago

0.3.52

1 year ago

0.3.57

1 year ago

0.3.56

1 year ago

0.3.55

1 year ago

0.3.54

1 year ago

0.3.51

1 year ago

0.3.50

1 year ago

0.3.49

1 year ago

0.3.48

1 year ago

0.3.47

1 year ago

0.3.46

1 year ago

0.3.45

1 year ago

0.3.44

1 year ago

0.3.43

2 years ago

0.3.39-beta.0

2 years ago

0.3.39

2 years ago

0.3.38

2 years ago

0.3.42

2 years ago

0.3.41

2 years ago

0.3.40

2 years ago

0.3.37

2 years ago

0.3.36

2 years ago

0.3.35

2 years ago

0.3.31

2 years ago

0.3.30

2 years ago

0.3.17

2 years ago

0.3.16

2 years ago

0.3.15

2 years ago

0.3.14

2 years ago

0.3.13

2 years ago

0.3.34

2 years ago

0.3.12

2 years ago

0.3.33

2 years ago

0.3.11

2 years ago

0.3.32

2 years ago

0.3.10

2 years ago

0.3.29

2 years ago

0.3.20

2 years ago

0.3.28

2 years ago

0.3.27

2 years ago

0.3.26

2 years ago

0.3.25

2 years ago

0.3.24

2 years ago

0.3.23

2 years ago

0.3.22

2 years ago

0.3.21

2 years ago

0.3.19

2 years ago

0.3.18

2 years ago

0.3.9

2 years ago

0.3.8

2 years ago

0.3.7

2 years ago

0.3.6

2 years ago

0.3.5

2 years ago

0.3.4

2 years ago

0.3.3

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago