1.47.0 • Published 3 days ago

@arianee/token-provider v1.47.0

Weekly downloads
-
License
-
Repository
-
Last release
3 days 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.47.0

3 days ago

1.46.0

27 days ago

1.45.0

1 month ago

1.44.0

1 month ago

1.43.0

1 month ago

1.42.0

1 month ago

1.41.0

2 months ago

1.38.0

2 months ago

1.39.0

2 months ago

1.40.0

2 months ago

1.37.0

2 months ago

1.36.0

2 months ago

1.35.0

2 months ago

1.34.0

2 months ago

1.33.0

3 months ago

1.32.0

3 months ago

1.31.0

3 months ago

1.30.1

3 months ago

1.30.0

4 months ago

1.29.2

4 months ago

1.29.1

4 months ago

1.26.0

4 months ago

1.29.0

4 months ago

1.27.0

4 months ago

1.28.0

4 months ago

1.25.0

4 months ago

1.24.0

4 months ago

1.23.0

4 months ago

0.1.0

4 months ago