@talismn/signet-apps-sdk
TypeScript icon, indicating that this package has built-in type declarations

0.0.7 • Public • Published

Signet Apps SDK

By integrating the Signet Apps SDK, your dapps can support multisig operations when users use your dapp within Signet.

Documentation

Installation

npm install @talismn/signet-apps-sdk
# or
yarn add @talismn/signet-apps-sdk
# or
bun add @talismn/signet-apps-sdk

Using the SDK

Check out this demo app for a complete example of how a dapp can support both EOA and multisig transactions with our SDK.

init() Check whether user is using your dapp within Signet.

import { SignetSdk } from "@talismn/signet-apps-sdk"
const sdk = new SignetSdk()

const inSignet = await sdk.init()
// true or false

If you're using React, we have a hook that handles that for you:

import { useSignetSdk } from "@talismn/signet-apps-sdk"

const App = () => {
  const { inSignet } = useSignetSdk()

  if (inSignet) return <p>{/* Inject and display signet vault*/}</p>
  return <button>Connect wallet</button>
}

getAccount() Inject the selected signet account into your dapp. The sdk is also exposed from our hook:

import { useSignetSdk, VaultAccount } from "@talismn/signet-apps-sdk"

const App = () => {
  const { inSignet, sdk } = useSignetSdk()
  const [injectedVault, setInjectedVault] = useState<VaultAccount>()

  const getVault = useCallback(async () => {
    const vault = await sdk.getAccount()
    setInjectedVault(vault)
  }, [])

  // depending on how your dapp is built, you may want to trigger this via a button click instead of useEffect
  useEffect(() => {
    if (inSignet) getVault()
  }, [inSignet, getVault])

  if (inSignet && injectedVault)
    return (
      <div>
        <p>{injectedVault.name}</p>
        <p>{injectedVault.address}</p>
      </div>
    )

  // handle normal EOA flow
  return <button>Connect wallet</button>
}

send(calldataHex: string) Send a transaction to Signet to be wrapped as a multisig transaction:

import { SendTxRespond } from '@talismn/signet-apps-sdk'

const App = () => {
    // ...

    const submitTx = () => {
        // ...build extrinsic
        const res = await sdk.send(extrinsic.method.toHex())
        console.log(res) // returns SendTxRespond
    }

    // ...
}

Readme

Keywords

none

Package Sidebar

Install

npm i @talismn/signet-apps-sdk

Weekly Downloads

30

Version

0.0.7

License

MIT

Unpacked Size

15.5 kB

Total Files

16

Last publish

Collaborators

  • chrisling-dev
  • tien-talisman
  • 0xkheops
  • jonpdunne
  • warp_lizard
  • alectalisman