1.84.0 • Published 9 months ago

@arianee/token-provider v1.84.0

Weekly downloads
-
License
-
Repository
-
Last release
9 months ago

@arianee/token-provider

A library for services and applications that need to generate Smart Asset Sharing Tokens (SST), a type of token that can be used to share the content and transfer rights of a smart asset on the Arianee protocol without losing ownership of the underlying smart asset.

Installation

npm install @arianee/token-provider

With older versions of npm, you may need to install the peer dependencies manually, see the peer depencies in the package.json file.

Usage

To generate a SST for the smart asset of id 123 owned by User A and to be consumed by User B, you need:

  • a Core instance of the smart asset owner (User A) (to sign the permit721 transaction needed to generate the SST)
  • the public key of the spender (User B) (the address that will be allowed to transfer the smart asset using the generated SST)
  • the address of the permit721 contract (permit721 addresses deployed by arianee are well known and can be found in the contract addresses JSONs)
import { generateSST } from '@arianee/token-provider';
import { SmartAsset } from '@arianee/common-types';
import { Wallet } from '@arianee/wallet';

const core = Core.fromPrivateKey('0xSMART_ASSET_OWNER_PRIVATE_KEY...'); // Core instance of the smart asset owner (User A)

const wallet = new Wallet({
  auth: {
    core,
  },
});

const smartAsset = await wallet.smartAsset.get('testnet', {
  id: '123',
}); // retrieve the smart asset with id 123 owned by User A (since the Wallet instance was initialized with the Core instance of User A, the smart asset can be retrieved without the view key)

const sst = await generateSST({
  core: core,
  smartAsset: smartAsset.data, // smart asset to generate a SST for
  spender: '0xSPENDER_ADDRESS', // the address that will be able to transfer the smart asset using the SST
  deadline: 3600, // OPTIONAL: the deadline of the SST in seconds (default is 30 days), you can use the `toDeadline` function of `@arianee/permit721-sdk` if needed
  nonce: 0, // OPTIONAL: the nonce of the SST (default is a random number between 0 and 1^6)
  permit721Address: '0xPERMIT_ADDRESS', // OPTIONAL: the address of the permit721 contract (default is `PERMIT721_ADDRESS` constant of `@arianee/permit721-sdk`)
});

Once generated, the SST can be consumed using the @arianee/service-provider library.

1.84.0

9 months ago

1.83.0

9 months ago

1.80.0

10 months ago

1.82.0

10 months ago

1.81.0

10 months ago

1.81.1

10 months ago

1.79.0

11 months ago

1.78.0

11 months ago

1.77.1

11 months ago

1.56.0

1 year ago

1.58.0

1 year ago

1.61.0

1 year ago

1.63.0

1 year ago

1.65.0

1 year ago

1.67.0

1 year ago

1.69.0

1 year ago

1.48.0

1 year ago

1.70.0

1 year ago

1.72.0

12 months ago

1.51.0

1 year ago

1.72.1

12 months ago

1.74.0

11 months ago

1.53.0

1 year ago

1.76.0

11 months ago

1.55.0

1 year ago

1.57.0

1 year ago

1.59.0

1 year ago

1.60.0

1 year ago

1.62.0

1 year ago

1.64.0

1 year ago

1.66.0

1 year ago

1.68.0

1 year ago

1.68.1

1 year ago

1.68.2

1 year ago

1.68.3

1 year ago

1.68.4

1 year ago

1.49.0

1 year ago

1.71.0

1 year ago

1.71.1

1 year ago

1.73.0

12 months ago

1.50.0

1 year ago

1.52.0

1 year ago

1.77.0

11 months ago

1.54.0

1 year ago

1.47.0

1 year ago

1.46.0

1 year ago

1.45.0

1 year ago

1.44.0

1 year ago

1.43.0

1 year ago

1.42.0

1 year ago

1.41.0

1 year ago

1.38.0

1 year ago

1.39.0

1 year ago

1.40.0

1 year ago

1.37.0

1 year ago

1.36.0

1 year ago

1.35.0

1 year ago

1.34.0

1 year ago

1.33.0

1 year ago

1.32.0

1 year ago

1.31.0

2 years ago

1.30.1

2 years ago

1.30.0

2 years ago

1.29.2

2 years ago

1.29.1

2 years ago

1.26.0

2 years ago

1.29.0

2 years ago

1.27.0

2 years ago

1.28.0

2 years ago

1.25.0

2 years ago

1.24.0

2 years ago

1.23.0

2 years ago

0.1.0

2 years ago