1.2.28 • Published 10 months ago

@greenton/sdk-react v1.2.28

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
10 months ago

@greenton/sdk-react 🌳

This is official NPM package of GreenTON. It contains messages for our contracts. Also here you can find pretty React hooks for sending transaction using TONConnect.

Usage 🛠️

import { Address, toNano } from '@ton/core';
import { useNftCollection } from '@greenton/sdk-react';

const MyComponent: React.FC = () => {
  const { mint } = useNftCollection();

  return (
    <button
      onClick={() =>
        mint({
          validUntil: Math.floor(Date.now() / 1000) + 360,
          message: {
            body: {
              $$type: 'Mint',
              tree: {
                $$type: 'Tree',
                name: 'Oak',
                type: 'basic',
                region: 'Africa',
                location: 'Forest',
              },
              destination: Address.parse('0QDasdGa9ZX8dhsF9qOJexH4-V4nh5Bg3Nwv45DA7f0ieoiM'),
              order_id: null,
            },
            address: 'kQA4PYQ9k12KTIMq4HziIoBZefo-ZJNID0s0Du0M-M6Fi7WG',
            amount: toNano('1'),
          },
        })
      }
    >
      Mint!
    </button>
  );
};

You are also open to directly use messages. For example to create your custom hook:

import { useTonConnectUI } from '@tonconnect/ui-react';
import { GREENTON_MESSAGES, NftCollectionMintArgs } from '@greenton/sdk-react';
import { TransactionArgs } from '~/types/TransactionArgs';

export default function usePerfectNftCollection() {
  const [tonConnectUI] = useTonConnectUI();

  return {
    mint: (args: TransactionArgs<NftCollectionMintArgs>) =>
      tonConnectUI.sendTransaction({
        validUntil: args.validUntil,
        messages: [GREENTON_MESSAGES.nftCollection.mint(args.message)],
      }),
  };
}

Bug reports 👾

If you have experienced any problems or found some bugs, please create an issue in this repository ❤️

1.2.28

10 months ago

1.2.27

10 months ago

1.2.26

10 months ago

1.2.25

10 months ago

1.2.24

10 months ago

1.2.23

10 months ago

1.2.22

10 months ago

1.2.21

10 months ago

1.2.20

10 months ago

1.2.19

10 months ago

1.2.18

10 months ago

1.2.17

10 months ago

1.2.16

10 months ago

1.2.15

10 months ago

1.2.14

11 months ago

1.2.13

11 months ago

1.2.12

11 months ago

1.2.11

11 months ago

1.2.10

11 months ago

1.2.9

11 months ago

1.2.8

11 months ago

1.2.7

11 months ago

1.2.6

11 months ago

1.2.5

11 months ago

1.2.4

11 months ago

1.2.3

11 months ago

1.2.2

11 months ago

1.2.1

11 months ago

1.2.0

11 months ago

1.0.9

11 months ago

1.0.8

11 months ago

1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago

0.0.0

11 months ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

0.0.1

1 year ago