2.7.23-64 • Published 2 years ago

@bloks/web-sdk v2.7.23-64

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Proton Web SDK

Installation

npm i @proton/web-sdk
yarn add @proton/web-sdk

Full Documentation: https://docs.protonchain.com/sdk/proton-web-sdk

Usage

import { ConnectWallet } from '@proton/web-sdk'

// Constants
const appIdentifier = 'taskly'

// Pop up modal
const link = await ConnectWallet({
    linkOptions: {
        endpoints: ['https://proton.greymass.com'],
        // rpc: rpc /* Optional: if you wish to provide rpc directly instead of endpoints */
    },
    transportOptions: {
        requestAccount: 'myprotonacc', /* Optional: Your proton account */
        requestStatus: true, /* Optional: Display request success and error messages, Default true */
    },
    selectorOptions: {
        appName: 'Taskly', /* Optional: Name to show in modal, Default 'app' */
        appLogo: 'https://protondemos.com/static/media/taskly-logo.ad0bfb0f.svg', /* Optional: Logo to show in modal */
        customStyleOptions: { /* Optional: Custom style options for modal */
            modalBackgroundColor: '#F4F7FA',
            logoBackgroundColor: 'white',
            isLogoRound: true,
            optionBackgroundColor: 'white',
            optionFontColor: 'black',
            primaryFontColor: 'black',
            secondaryFontColor: '#6B727F',
            linkColor: '#752EEB'
        }
        // walletType: 'proton' /* Optional: Connect to only specified wallet (e.g. 'proton', 'anchor') */
    }
})

//Login
  const { link, session } = await ConnectWallet({
    linkOptions: { chainId: this.chainId, endpoints: this.endpoints },
    transportOptions: { requestAccount: this.requestAccount, backButton: true },
    selectorOptions: { appName: this.appName, appLogo: appLogo}
  });
  this.link = link;
  this.session = session;
  return { auth: session.auth };

// Send Transaction
const result = await session.transact({
    transaction: {
        actions: [{
            // Token contract for XUSDT
            account: 'xtokens',
            // Action name
            name: 'transfer',
            // Action parameters
            data: {
                from: session.auth.actor,
                to: 'syed',
                quantity: '0.000001 XUSDT',
                memo: 'Tip!'
            },
            authorization: [session.auth]
        }]
    },
    broadcast: true
})
console.log('Transaction ID', result.processed.id)

// Restore session after refresh (must recreate link first with restoreSession as true)
const { link, session } = await ConnectWallet({
    linkOptions: { chainId: this.chainId, endpoints: this.endpoints, restoreSession: true},
    transportOptions: { requestAccount: this.requestAccount },
    selectorOptions: { appName: this.appName, appLogo: appLogo}
  });
  this.link = link;
  this.session = session;
      
// Logout
await link.removeSession(appIdentifier, session.auth)
session = undefined
2.7.23-58

2 years ago

2.7.23-59

2 years ago

2.7.23-57

2 years ago

2.7.23-63

2 years ago

2.7.23-64

2 years ago

2.7.23-61

2 years ago

2.7.23-62

2 years ago

2.7.23-60

2 years ago

2.7.23-56

3 years ago

2.7.23-54

3 years ago

2.7.23-55

3 years ago

2.7.23-52

3 years ago

2.7.23-53

3 years ago

2.7.23-49

3 years ago

2.7.23-47

3 years ago

2.7.23-48

3 years ago

2.7.23-50

3 years ago

2.7.23-51

3 years ago

2.7.23-45

3 years ago

2.7.23-46

3 years ago

2.7.23-43

3 years ago

2.7.23-44

3 years ago

2.7.23-41

3 years ago

2.7.23-42

3 years ago

2.7.23-40

3 years ago

2.7.23-38

3 years ago

2.7.23-39

3 years ago

2.7.23-36

3 years ago

2.7.23-37

3 years ago

2.7.23-34

3 years ago

2.7.23-35

3 years ago

2.7.23-32

3 years ago

2.7.23-31

3 years ago

2.7.23-30

3 years ago

2.7.23-27

3 years ago

2.7.23-28

3 years ago

2.7.23-25

3 years ago

2.7.23-26

3 years ago

2.7.23-24

3 years ago

2.7.23-21

3 years ago

2.7.23-20

3 years ago

2.7.23-18

3 years ago

2.7.23-19

3 years ago

2.7.23-29

3 years ago

2.7.23-16

3 years ago

2.7.23-17

3 years ago

2.7.23-15

3 years ago

2.7.23-14

3 years ago

2.7.23-12

3 years ago

2.7.23-13

3 years ago

2.7.23-10

3 years ago

2.7.23-11

3 years ago

2.7.23-9

3 years ago

2.7.23-8

3 years ago

2.7.23-7

3 years ago

2.7.23-6

3 years ago

2.7.23-4

3 years ago

2.7.23-3

3 years ago

2.7.23-2

3 years ago

2.7.23-1

3 years ago

2.7.23

3 years ago