@campnetwork/origin 1.0.0-alpha.14 → 1.0.0-alpha.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,10 +15,10 @@
15
15
  The Origin SDK currently exposes the following modules:
16
16
 
17
17
  - `"@campnetwork/origin"` - The main entry point for the SDK, exposes the following classes:
18
- - `TwitterAPI` - For fetching user Twitter data from the Auth Hub
19
- - `SpotifyAPI` - For fetching user Spotify data from the Auth Hub
18
+ - `TwitterAPI` - For fetching user Twitter data from Origin
19
+ - `SpotifyAPI` - For fetching user Spotify data from Origin
20
20
  - `Auth` - For authenticating users with the Origin SDK
21
- - `"@campnetwork/origin/react"` - Exposes the CampProvider and CampContext, as well as React components and hooks for authentication and fetching user data via the Camp Auth Hub
21
+ - `"@campnetwork/origin/react"` - Exposes the CampProvider and CampContext, as well as React components and hooks for authentication and fetching user data via Origin
22
22
 
23
23
  # Installation
24
24
 
@@ -46,7 +46,7 @@ import { TwitterAPI, SpotifyAPI, Auth } from "@campnetwork/origin";
46
46
 
47
47
  ### TwitterAPI
48
48
 
49
- The TwitterAPI class is the entry point for fetching user Twitter data from the Auth Hub. It requires an API key to be instantiated.
49
+ The TwitterAPI class is the entry point for fetching user Twitter data from Origin. It requires an API key to be instantiated.
50
50
 
51
51
  **Note: The methods for fetching data will only return data for users who have authenticated to your app via the Origin SDK.**
52
52
 
@@ -152,7 +152,7 @@ const viewedTweets = await twitter.fetchViewedTweetsByUsername("jack", 1, 10);
152
152
 
153
153
  ### SpotifyAPI
154
154
 
155
- The SpotifyAPI class is the entry point for fetching user Spotify data from the Auth Hub. It requires an API key to be instantiated.
155
+ The SpotifyAPI class is the entry point for fetching user Spotify data from Origin. It requires an API key to be instantiated.
156
156
 
157
157
  **Note: The methods for fetching data will only return data for users who have authenticated to your app via the Origin SDK.**
158
158
 
@@ -226,7 +226,7 @@ const user = await spotify.fetchUserByWalletAddress("0x1234567890");
226
226
 
227
227
  ### TikTokAPI
228
228
 
229
- The TikTokAPI class is the entry point for fetching user TikTok data from the Auth Hub. It requires an API key to be instantiated.
229
+ The TikTokAPI class is the entry point for fetching user TikTok data from Origin. It requires an API key to be instantiated.
230
230
 
231
231
  **Note: The methods for fetching data will only return data for users who have authenticated to your app via the Origin SDK.**
232
232
 
@@ -270,9 +270,7 @@ The Auth class is the entry point for authenticating users with the Origin SDK.
270
270
  - `redirectUri` - The URI to redirect to after the user completes oauth for any of the socials. Defaults to `window.location.href`.
271
271
  The `redirectUri` can also be an object with the following optional properties:
272
272
  - `twitter` - The URI to redirect to after the user completes oauth for Twitter.
273
- - `discord` - The URI to redirect to after the user completes oauth for Discord.
274
273
  - `spotify` - The URI to redirect to after the user completes oauth for Spotify.
275
- - `allowAnalytics` - Whether to allow analytics to be collected. Defaults to `true`.
276
274
 
277
275
  You may use the `redirectUri` object to redirect the user to different pages based on the social they are linking.
278
276
  You may only define the URIs for the socials you are using, the rest will default to `window.location.href`.
@@ -292,7 +290,6 @@ const auth = new Auth({
292
290
  clientId: "your-client-id",
293
291
  redirectUri: {
294
292
  twitter: "https://your-website.com/twitter",
295
- discord: "https://your-website.com/discord",
296
293
  spotify: "https://your-website.com/spotify",
297
294
  },
298
295
  });
@@ -323,7 +320,7 @@ auth.disconnect();
323
320
 
324
321
  #### setProvider
325
322
 
326
- `setProvider(provider: { provider: EIP1193Provider, info: EIP6963ProviderInfo }) => void`
323
+ `setProvider(provider: { provider: EIP1193Provider, info: EIP6963ProviderInfo, address?: string }) => void`
327
324
 
328
325
  _Read more about the [EIP1193Provider](https://eips.ethereum.org/EIPS/eip-1193) and [EIP6963ProviderInfo](https://eips.ethereum.org/EIPS/eip-6963) interfaces._
329
326
 
@@ -405,16 +402,26 @@ auth.on("providers", (data) => {
405
402
  });
406
403
  ```
407
404
 
405
+ #### off
406
+
407
+ `off(event: string, callback: (data: any) => void) => void`
408
+
409
+ The `off` method unsubscribes from events emitted by the Auth module of the Origin SDK.
410
+
411
+ ```js
412
+ auth.off("state", callback);
413
+ ```
414
+
408
415
  #### getLinkedSocials
409
416
 
410
- `getLinkedSocials() => Promise<{ twitter: boolean, discord: boolean, spotify: boolean }>`
417
+ `getLinkedSocials() => Promise<{ twitter: boolean, tiktok: boolean, spotify: boolean }>`
411
418
 
412
419
  The `getLinkedSocials` method returns a promise that resolves to an object containing the possible socials that the user can link and whether they are linked or not.
413
420
 
414
421
  ```js
415
422
  const linkedSocials = await auth.getLinkedSocials();
416
423
 
417
- console.log(linkedSocials); // { twitter: true, discord: false, spotify: true }
424
+ console.log(linkedSocials); // { twitter: true, tiktok: false, spotify: true }
418
425
  ```
419
426
 
420
427
  ---
@@ -427,27 +434,17 @@ Afterwards, the user will be redirected back to the `redirectUri` specified in t
427
434
 
428
435
  `linkTwitter() => void`
429
436
 
430
- The `linkTwitter` method redirects the user to the Twitter OAuth flow to link their Twitter account to the Auth Hub.
437
+ The `linkTwitter` method redirects the user to the Twitter OAuth flow to link their Twitter account to Origin.
431
438
 
432
439
  ```js
433
440
  auth.linkTwitter();
434
441
  ```
435
442
 
436
- #### linkDiscord
437
-
438
- `linkDiscord() => void`
439
-
440
- The `linkDiscord` method redirects the user to the Discord OAuth flow to link their Discord account to the Auth Hub.
441
-
442
- ```js
443
- auth.linkDiscord();
444
- ```
445
-
446
443
  #### linkSpotify
447
444
 
448
445
  `linkSpotify() => void`
449
446
 
450
- The `linkSpotify` method redirects the user to the Spotify OAuth flow to link their Spotify account to the Auth Hub.
447
+ The `linkSpotify` method redirects the user to the Spotify OAuth flow to link their Spotify account to Origin.
451
448
 
452
449
  ```js
453
450
  auth.linkSpotify();
@@ -457,58 +454,29 @@ auth.linkSpotify();
457
454
 
458
455
  `linkTikTok(handle: string) => Promise<void>`
459
456
 
460
- The `linkTikTok` method links the provided TikTok handle to the Auth Hub.
457
+ The `linkTikTok` method links the provided TikTok handle to Origin.
461
458
 
462
459
  ```js
463
460
  auth.linkTikTok("tiktokhandle");
464
461
  ```
465
462
 
466
- #### sendTelegramOTP
467
-
468
- `sendTelegramOTP(phoneNumber: string) => Promise<void>`
469
- The `sendTelegramOTP` method sends an OTP to the provided phone number via Telegram. The OTP can be used via the `linkTelegram` method to link the user's Telegram account to the Auth Hub.
470
-
471
- ```js
472
- const { phone_code_hash } = await auth.sendTelegramOTP("+1234567890");
473
- ```
474
-
475
- #### linkTelegram
476
-
477
- `linkTelegram(phoneNumber: string, otp: string, phoneCodeHash: string) => Promise<void>`
478
-
479
- The `linkTelegram` method links the provided phone number to the Auth Hub using the OTP and phone code hash received from the `sendTelegramOTP` method.
480
-
481
- ```js
482
- await auth.linkTelegram("+1234567890", "123456", "abc123");
483
- ```
484
-
485
463
  ---
486
464
 
487
465
  #### unlinkTwitter
488
466
 
489
467
  `unlinkTwitter() => Promise<void>`
490
468
 
491
- The `unlinkTwitter` method unlinks the user's Twitter account from the Auth Hub.
469
+ The `unlinkTwitter` method unlinks the user's Twitter account from Origin.
492
470
 
493
471
  ```js
494
472
  await auth.unlinkTwitter();
495
473
  ```
496
474
 
497
- #### unlinkDiscord
498
-
499
- `unlinkDiscord() => Promise<void>`
500
-
501
- The `unlinkDiscord` method unlinks the user's Discord account from the Auth Hub.
502
-
503
- ```js
504
- await auth.unlinkDiscord();
505
- ```
506
-
507
475
  #### unlinkSpotify
508
476
 
509
477
  `unlinkSpotify() => Promise<void>`
510
478
 
511
- The `unlinkSpotify` method unlinks the user's Spotify account from the Auth Hub.
479
+ The `unlinkSpotify` method unlinks the user's Spotify account from Origin.
512
480
 
513
481
  ```js
514
482
  await auth.unlinkSpotify();
@@ -518,21 +486,12 @@ await auth.unlinkSpotify();
518
486
 
519
487
  `unlinkTikTok() => Promise<void>`
520
488
 
521
- The `unlinkTikTok` method unlinks the user's TikTok account from the Auth Hub.
489
+ The `unlinkTikTok` method unlinks the user's TikTok account from Origin.
522
490
 
523
491
  ```js
524
492
  await auth.unlinkTikTok();
525
493
  ```
526
494
 
527
- #### unlinkTelegram
528
-
529
- `unlinkTelegram() => Promise<void>`
530
- The `unlinkTelegram` method unlinks the user's Telegram account from the Auth Hub.
531
-
532
- ```js
533
- await auth.unlinkTelegram();
534
- ```
535
-
536
495
  # React
537
496
 
538
497
  The React components and hooks can be imported as ES6 modules. The example below shows how to set up the `CampProvider` component and subsequently use the provided hooks and components.
@@ -563,7 +522,9 @@ createRoot(document.getElementById("root")).render(
563
522
  The `CampProvider` component requires a `clientId` prop to be passed in order link the users to your app.
564
523
  It can also take the following optional props:
565
524
 
566
- - `redirectUri` - `string | object` - Either a string that will be used as the redirect URI for all socials, or an object with the following optional properties: `twitter`, `discord`, `spotify`. This is used to redirect the user to different pages after they have completed the OAuth flow for a social.
525
+ - `redirectUri` - `string | object` - Either a string that will be used as the redirect URI for all socials, or an object with the following optional properties: `twitter`, `spotify`. This is used to redirect the user to different pages after they have completed the OAuth flow for a social.
526
+ - `environment` - `string` - The environment to use. Can be either `DEVELOPMENT` or `PRODUCTION`. Defaults to `DEVELOPMENT`.
527
+ - - the `DEVELOPMENT` environment uses the Camp Testnet while the `PRODUCTION` environment uses the Camp Mainnet.
567
528
 
568
529
  ```jsx
569
530
  import { CampProvider } from "@campnetwork/origin/react";
@@ -573,6 +534,7 @@ function App() {
573
534
  <CampProvider
574
535
  clientId="your-client-id"
575
536
  redirectUri="https://your-website.com"
537
+ environment="DEVELOPMENT"
576
538
  >
577
539
  <div>Your app</div>
578
540
  </CampProvider>
@@ -591,9 +553,9 @@ function App() {
591
553
  clientId="your-client-id"
592
554
  redirectUri={{
593
555
  twitter: "https://your-website.com/twitter",
594
- discord: "https://your-website.com/discord",
595
556
  spotify: "https://your-website.com/spotify",
596
557
  }}
558
+ environment="DEVELOPMENT"
597
559
  >
598
560
  <div>Your app</div>
599
561
  </CampProvider>
@@ -605,15 +567,15 @@ The `CampProvider` component sets up the context for the Origin SDK and provides
605
567
 
606
568
  ## CampModal
607
569
 
608
- ![@campnetwork/origin](https://imgur.com/n9o0rJ3.png)
570
+ ![@campnetwork/origin](https://imgur.com/AFmorL4.png)
609
571
 
610
- The **CampModal** is a one-line\* solution for authenticating users with the Origin SDK. It can be used to connect users to the Auth Hub and link and unlink social accounts.
572
+ The **CampModal** is a one-line\* solution for authenticating users with the Origin SDK. It can be used to connect users to Origin, link and unlink social accounts, mint IPNFTs, and view the user's Origin stats.
611
573
 
612
574
  It works as follows:
613
575
 
614
576
  The **CampModal** component displays a button with the text "**Connect**" that the user can click on in order to summon the modal. The modal shows a list of available providers that the user can select from. After a provider has been selected, the `connect` method is called on the Auth instance to authenticate the user.
615
577
 
616
- If the user is already authenticated, the button will instead say "**My Camp**" and the modal will display the user's Camp profile information and allow them to link and unlink social accounts.
578
+ If the user is already authenticated, the button will instead say "**My Origin**" and the modal will display the user's Origin profile information and allow them to link and unlink social accounts.
617
579
 
618
580
  The **CampModal** can take the following props:
619
581
 
@@ -621,7 +583,6 @@ The **CampModal** can take the following props:
621
583
  - `injectButton` - `boolean` - Whether to inject the button into the DOM or not. Defaults to `true`. If set to `false`, the button will not be rendered and the modal can be opened programmatically via the `openModal` function returned by the `useModal` hook.
622
584
  - `onlyWagmi` - `boolean` - Whether to only show the provider that the user is currently authenticated with. Defaults to `false`.
623
585
  - `defaultProvider` - `{ provider: EIP1193Provider, info: EIP6963ProviderInfo, exclusive: boolean }` - Custom provider to set as the highlighted provider in the modal. If not set, the wagmi provider will be highlighted if it is available. The `exclusive` property can be set to `true` to only show this provider in the modal.
624
- - `allowAnalytics` - `boolean` - Whether to allow analytics to be collected. Defaults to `true`.
625
586
 
626
587
  ### Usage
627
588
 
@@ -680,7 +641,7 @@ Users can be authenticated either via the Camp Modal as outlined above or progra
680
641
 
681
642
  ### Usage with third party providers (Privy, Appkit, Magic, etc.)
682
643
 
683
- The Camp Modal can be used in conjunction with providers such as Privy and Appkit to create a seamless authentication experience for users. When using wagmi, it will automatically detect if the user is authenticated via a third party provider and give them the option to connect to the Auth Hub using that provider. Otherwise, you can set up the default provider to be whatever provider you are using.
644
+ The Camp Modal can be used in conjunction with providers such as Privy and Appkit to create a seamless authentication experience for users. When using wagmi, it will automatically detect if the user is authenticated via a third party provider and give them the option to connect to Origin using that provider. Otherwise, you can set up the default provider to be whatever provider you are using.
684
645
 
685
646
  [Example usage with Privy](./examples/client-side/react/privy-connector/)
686
647
 
@@ -696,7 +657,7 @@ The **LinkButton** component is a button that can be used to link and unlink soc
696
657
 
697
658
  The **LinkButton** can take the following props:
698
659
 
699
- - `social` - `string` - The social account to link or unlink. Can be one of: `twitter`, `discord`, `spotify`.
660
+ - `social` - `string` - The social account to link or unlink. Can be one of: `twitter`, `tiktok`, `spotify`.
700
661
  - `variant` - `string` - The variant of the button. Can be one of: `default`, `icon`. Defaults to `default`.
701
662
  - `theme` - `string` - The theme of the button. Can be one of: `default`, `camp`. Defaults to `default`.
702
663
 
@@ -714,10 +675,25 @@ function App() {
714
675
  <div>
715
676
  <CampModal />
716
677
  <LinkButton social="twitter" />
717
- <LinkButton social="discord" variant="icon" />
718
678
  <LinkButton social="spotify" theme="camp" />
719
679
  <LinkButton social="tiktok" variant="icon" theme="camp" />
720
- <LinkButton social="telegram" />
680
+ </div>
681
+ );
682
+ }
683
+ ```
684
+
685
+ ## CampButton
686
+
687
+ The **CampButton** component allows you to render a button that opens the Auth or My Origin modal when clicked. It can be used as an alternative to the button that is injected by the **CampModal** component. It allows you to have multiple buttons in your app that open the modal, or to have the button in a different location than where the **CampModal** component is rendered.
688
+
689
+ ```jsx
690
+ import { CampButton, CampModal } from "@campnetwork/origin/react";
691
+
692
+ function App() {
693
+ return (
694
+ <div>
695
+ <CampModal injectButton={false} />
696
+ <CampButton />
721
697
  </div>
722
698
  );
723
699
  }
@@ -850,7 +826,7 @@ function App() {
850
826
  return (
851
827
  <div>
852
828
  <div>Twitter: {data.twitter ? "Linked" : "Not linked"}</div>
853
- <div>Discord: {data.discord ? "Linked" : "Not linked"}</div>
829
+ <div>Tiktok: {data.tiktok ? "Linked" : "Not linked"}</div>
854
830
  <div>Spotify: {data.spotify ? "Linked" : "Not linked"}</div>
855
831
  </div>
856
832
  );
@@ -867,35 +843,22 @@ import { useLinkSocials } from "@campnetwork/origin/react";
867
843
  function App() {
868
844
  const {
869
845
  linkTwitter,
870
- linkDiscord,
871
846
  linkSpotify,
872
847
  linkTiktok,
873
- linkTelegram,
874
- sendTelegramOTP,
875
848
  unlinkTwitter,
876
- unlinkDiscord,
877
849
  unlinkSpotify,
878
850
  unlinkTiktok,
879
- unlinkTelegram,
880
851
  } = useLinkSocials();
881
852
 
882
853
  return (
883
854
  <div>
884
855
  <button onClick={linkTwitter}>Link Twitter</button>
885
- <button onClick={linkDiscord}>Link Discord</button>
886
856
  <button onClick={linkSpotify}>Link Spotify</button>
887
857
  <button onClick={() => linkTiktok("tiktokhandle")}>Link TikTok</button>
888
- <button onClick={() => sendTelegramOTP("+1234567890")}>
889
- Send Telegram OTP
890
- </button>
891
- <button onClick={() => linkTelegram("+1234567890", "123456", "abc123")}>
892
- Link Telegram
893
858
  </button>
894
859
  <button onClick={unlinkTwitter}>Unlink Twitter</button>
895
- <button onClick={unlinkDiscord}>Unlink Discord</button>
896
- <button onClick={unlinkSpotify}>Unlink Spotify</button>
897
860
  <button onClick={unlinkTiktok}>Unlink TikTok</button>
898
- <button onClick={unlinkTelegram}>Unlink Telegram</button>
861
+ <button onClick={unlinkSpotify}>Unlink Spotify</button>
899
862
  </div>
900
863
  );
901
864
  }
@@ -903,7 +866,7 @@ function App() {
903
866
 
904
867
  ### useModal
905
868
 
906
- The `useModal` hook returns the state of the Auth and My Camp modals, as well as functions to show and hide them.
869
+ The `useModal` hook returns the state of the Auth and My Origin modals, as well as functions to show and hide them.
907
870
 
908
871
  **Note: The `<CampModal/>` component must be rendered in the component tree for the modals to be displayed.**
909
872
 
@@ -923,7 +886,7 @@ function App() {
923
886
  }
924
887
  ```
925
888
 
926
- The state and functions returned by the `useModal` hook can be used to show and hide the Auth and My Camp modals, as well as to check if they are currently open. The modal being controlled is dictated by the user's authentication state.
889
+ The state and functions returned by the `useModal` hook can be used to show and hide the Auth and My Origin modals, as well as to check if they are currently open. The modal being controlled is dictated by the user's authentication state.
927
890
 
928
891
  ### useLinkModal
929
892
 
@@ -950,20 +913,15 @@ It returns the following properties and functions:
950
913
 
951
914
  - `isLinkingOpen` - `boolean` - Whether the Link Socials modal is open or not.
952
915
  - `openTwitterModal` - `() => void`
953
- - `openDiscordModal` - `() => void`
954
916
  - `openSpotifyModal` - `() => void`
955
917
  - `openTiktokModal` - `() => void`
956
- - `openTelegramModal` - `() => void`
957
918
  - `linkTwitter` - `() => void`
958
- - `linkDiscord` - `() => void`
959
919
  - `linkSpotify` - `() => void`
960
920
  - `linkTiktok` - `() => void`
961
921
  - `linkTelegram` - `() => void`
962
922
  - `unlinkTwitter` - `() => void`
963
- - `unlinkDiscord` - `() => void`
964
923
  - `unlinkSpotify` - `() => void`
965
924
  - `unlinkTiktok` - `() => void`
966
- - `unlinkTelegram` - `() => void`
967
925
  - `closeModal` - `() => void`
968
926
 
969
927
  The difference between the `openXModal` functions and the `linkX / unlinkX` functions is that the former opens the modal regardless of the user's linking state, allowing them to either link or unlink their account, while the latter only opens the specified modal if the user's linking state allows for it.
@@ -972,7 +930,7 @@ For example, if the user is linked to Twitter, calling `openTwitterModal` will o
972
930
 
973
931
  ## Origin Methods (`auth.origin`)
974
932
 
975
- The `Origin` class provides methods for interacting with Origin IpNFTs, uploading files, managing user stats, and more. You can access these methods via `auth.origin` after authentication.
933
+ The `Origin` class provides blockchain and API methods for interacting with Origin IpNFTs, uploading files, managing user stats, and more. Access these via `auth.origin` after authentication.
976
934
 
977
935
  ### Types
978
936
 
@@ -984,124 +942,100 @@ The license terms object used in minting and updating methods:
984
942
  type LicenseTerms = {
985
943
  price: bigint; // Price in wei
986
944
  duration: number; // Duration in seconds
987
- royaltyBps: number; // Royalty in basis points (0-10000)
945
+ royaltyBps: number; // Royalty in basis points (1-10000)
988
946
  paymentToken: Address; // Payment token address (address(0) for native currency)
989
947
  };
990
948
  ```
991
949
 
950
+ ### Minting Constraints
951
+
952
+ When minting or updating an IpNFT, the following constraints apply to the `LicenseTerms`:
953
+
954
+ - The price must be at least `1000000000000000` wei (0.001 $CAMP).
955
+ - The royaltyBps must be between `1` and `10000` (0.01% to 100%).
956
+ - The duration must be at least `86400` seconds (1 day).
957
+
992
958
  ### File Upload & Minting
993
959
 
994
- #### `mintFile(file: File, metadata: Record<string, unknown>, license: LicenseTerms, parentId?: bigint, options?: { progressCallback?: (percent: number) => void })`
960
+ #### `mintFile(file, metadata, license, parents?, options?)`
995
961
 
996
962
  Uploads a file and mints an IpNFT for it.
997
963
 
998
- - `file`: The file to upload and mint.
999
- - `metadata`: Additional metadata for the IpNFT.
1000
- - `license`: License terms for the IpNFT (price, duration, royalty, payment token).
1001
- - `parentId`: Optional parent token ID for derivative works.
1002
- - `options.progressCallback`: Optional progress callback.
1003
- - **Returns:** The minted token ID as a string, or throws an error on failure.
964
+ - `file`: File to upload and mint
965
+ - `metadata`: Additional metadata for the IpNFT
966
+ - `name`: Name of the IpNFT
967
+ - `description`: Description of the IpNFT
968
+ - `image`: Optional image URL for the IpNFT
969
+ - `attributes`: Optional array of attributes
970
+ - `license`: LicenseTerms object
971
+ - `parents`: Optional array of parent token IDs for derivatives
972
+ - `options.progressCallback`: Optional progress callback
973
+ - **Returns:** Minted token ID as a string, or throws on failure
1004
974
 
1005
- #### `mintSocial(source: "spotify" | "twitter" | "tiktok", license: LicenseTerms)`
975
+ #### `mintSocial(source, metadata, license)`
1006
976
 
1007
977
  Mints an IpNFT for a connected social account.
1008
978
 
1009
- - `source`: The social platform.
1010
- - `license`: License terms for the IpNFT.
1011
- - **Returns:** The minted token ID as a string, or throws an error on failure.
979
+ - `source`: Social platform (`"spotify" | "twitter" | "tiktok"`)
980
+ - `metadata`: Additional metadata for the IpNFT
981
+ - `license`: LicenseTerms object
982
+ - **Returns:** Minted token ID as a string, or throws on failure
1012
983
 
1013
984
  ### IpNFT & Marketplace Methods
1014
985
 
1015
- The following methods are available for interacting with IpNFTs and the marketplace. All methods mirror the smart contract functions and require appropriate permissions.
986
+ Most methods mirror smart contract functions and require appropriate permissions.
1016
987
 
1017
988
  #### Core IpNFT Methods
1018
989
 
1019
- - `mintWithSignature(account: string, tokenId: bigint, parentId: bigint, creatorContentHash: string, uri: string, license: LicenseTerms, deadline: bigint, signature: string)` - Mint an IpNFT with a signature
1020
- - `registerIpNFT(source: string, deadline: bigint, license: LicenseTerms, metadata: Record<string, unknown>, fileKey?: string, parentId?: bigint)` - Register an IpNFT for minting
1021
- - `updateTerms(tokenId: bigint, license: LicenseTerms)` - Update license terms for an IpNFT
1022
- - `requestDelete(tokenId: bigint)` - Request deletion of an IpNFT
1023
- - `getTerms(tokenId: bigint)` - Get license terms for an IpNFT
1024
- - `ownerOf(tokenId: bigint)` - Get the owner of an IpNFT
1025
- - `balanceOf(owner: string)` - Get the balance of IpNFTs for an owner
1026
- - `contentHash(tokenId: bigint)` - Get the content hash of an IpNFT
1027
- - `tokenURI(tokenId: bigint)` - Get the metadata URI of an IpNFT
1028
- - `dataStatus(tokenId: bigint)` - Get the data status of an IpNFT
1029
- - `royaltyInfo(tokenId: bigint, value: bigint)` - Get royalty information
1030
- - `getApproved(tokenId: bigint)` - Get the approved address for an IpNFT
1031
- - `isApprovedForAll(owner: string, operator: string)` - Check if operator is approved for all tokens
1032
- - `transferFrom(from: string, to: string, tokenId: bigint)` - Transfer an IpNFT
1033
- - `safeTransferFrom(from: string, to: string, tokenId: bigint)` - Safely transfer an IpNFT
1034
- - `approve(to: string, tokenId: bigint)` - Approve an address for a specific IpNFT
1035
- - `setApprovalForAll(operator: string, approved: boolean)` - Set approval for all tokens
990
+ - `mintWithSignature(account, tokenId, parents, creatorContentHash, uri, license, deadline, signature)`
991
+ - `registerIpNFT(source, deadline, license, metadata, fileKey?, parents?)`
992
+ - `updateTerms(tokenId, license)`
993
+ - `finalizeDelete(tokenId)`
994
+ - `getOrCreateRoyaltyVault(tokenId)`
995
+ - `getTerms(tokenId)`
996
+ - `ownerOf(tokenId)`
997
+ - `balanceOf(owner)`
998
+ - `tokenURI(tokenId)`
999
+ - `dataStatus(tokenId)`
1000
+ - `isApprovedForAll(owner, operator)`
1001
+ - `transferFrom(from, to, tokenId)`
1002
+ - `safeTransferFrom(from, to, tokenId)`
1003
+ - `approve(to, tokenId)`
1004
+ - `setApprovalForAll(operator, approved)`
1036
1005
 
1037
1006
  #### Marketplace Methods
1038
1007
 
1039
- - `buyAccess(tokenId: bigint, periods: number, value?: bigint)` - Buy access to an IpNFT
1040
- - `renewAccess(tokenId: bigint, periods: number)` - Renew access to an IpNFT
1041
- - `hasAccess(tokenId: bigint, user: string)` - Check if user has access to an IpNFT
1042
- - `subscriptionExpiry(tokenId: bigint, user: string)` - Get subscription expiry for a user
1043
-
1044
- > See the SDK source or contract ABI for full parameter details.
1045
-
1046
- #### `buyAccessSmart(tokenId: bigint, periods: number)`
1008
+ - `buyAccess(tokenId, periods, value?)`
1009
+ - `hasAccess(tokenId, user)`
1010
+ - `subscriptionExpiry(tokenId, user)`
1047
1011
 
1048
- Buys access to an asset, handling payment approval if needed.
1012
+ #### Utility & Royalty Methods
1049
1013
 
1050
- - `tokenId`: The IpNFT token ID.
1051
- - `periods`: Number of periods to buy.
1052
- - **Returns:** Result of the buy access transaction.
1014
+ - `getRoyalties(token?, owner?)` Get royalty vault and balance
1015
+ - `claimRoyalties(token?, owner?)` Claim royalties
1053
1016
 
1054
- #### `getData(tokenId: bigint)`
1017
+ #### Smart Access & Data
1055
1018
 
1056
- Fetches metadata for a given IpNFT.
1057
-
1058
- - `tokenId`: The IpNFT token ID.
1059
- - **Returns:** Data object for the token.
1019
+ - `buyAccessSmart(tokenId)` Buys access, handles payment approval and license details
1020
+ - `getData(tokenId)` — Fetches metadata for a given IpNFT
1060
1021
 
1061
1022
  ### User Data & Stats
1062
1023
 
1063
- #### `getOriginUploads()`
1064
-
1065
- Fetches the user's Origin file uploads.
1066
-
1067
- - **Returns:** Array of upload data, or `null` on failure.
1068
-
1069
- #### `getOriginUsage()`
1070
-
1071
- Fetches the user's Origin stats (multiplier, points, usage, etc).
1072
-
1073
- - **Returns:** Object with user stats including:
1074
- - `user.multiplier` - User's Origin multiplier
1075
- - `user.points` - User's Origin points
1076
- - `user.active` - Whether user's Origin is active
1077
- - `teams` - Array of team data
1078
- - `dataSources` - Array of data source information
1079
-
1080
- #### `setOriginConsent(consent: boolean)`
1081
-
1082
- Sets the user's consent for Origin usage.
1083
-
1084
- - `consent`: `true` or `false`.
1085
- - **Returns:** Promise that resolves on success, throws APIError on failure.
1024
+ - `getOriginUploads()` — Fetch user's Origin file uploads (returns array or null)
1025
+ - `getOriginUsage()` — Fetch user's Origin stats (returns object with multiplier, points, active, teams, dataSources)
1026
+ - `setOriginConsent(consent: boolean)` — Set user's consent for Origin usage
1086
1027
 
1087
1028
  ### Utility Methods
1088
1029
 
1089
- #### `getJwt()`
1090
-
1091
- Gets the current JWT token.
1030
+ - `getJwt()` — Get current JWT token
1031
+ - `setViemClient(client)` — Set viem wallet client for blockchain interactions
1092
1032
 
1093
- - **Returns:** The JWT string.
1094
-
1095
- #### `setViemClient(client: any)`
1096
-
1097
- Sets the viem wallet client for blockchain interactions.
1033
+ ---
1098
1034
 
1099
- - `client`: The viem wallet client instance.
1035
+ Call these methods as `await auth.origin.methodName(...)` after authenticating. See inline code documentation for full details and parameter types.
1100
1036
 
1101
1037
  ---
1102
1038
 
1103
- You can call these methods as `await auth.origin.methodName(...)` after authenticating with the SDK. For more details, see the inline code documentation.
1104
-
1105
1039
  # Contributing
1106
1040
 
1107
1041
  Install the dependencies.
@@ -1127,7 +1061,7 @@ npm run dev
1127
1061
  In order to use the sdk in a local project, you can link the sdk to the project.
1128
1062
 
1129
1063
  ```bash
1130
- npm link
1064
+ npm link .
1131
1065
  ```
1132
1066
 
1133
1067
  Then, in the project you want to use the sdk in, run: