2.7.23-64 • Published 4 years ago

@bloks/web-sdk v2.7.23-64

Weekly downloads
-
License
MIT
Repository
-
Last release
4 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

4 years ago

2.7.23-59

4 years ago

2.7.23-57

4 years ago

2.7.23-63

4 years ago

2.7.23-64

4 years ago

2.7.23-61

4 years ago

2.7.23-62

4 years ago

2.7.23-60

4 years ago

2.7.23-56

4 years ago

2.7.23-54

4 years ago

2.7.23-55

4 years ago

2.7.23-52

4 years ago

2.7.23-53

4 years ago

2.7.23-49

4 years ago

2.7.23-47

4 years ago

2.7.23-48

4 years ago

2.7.23-50

4 years ago

2.7.23-51

4 years ago

2.7.23-45

4 years ago

2.7.23-46

4 years ago

2.7.23-43

4 years ago

2.7.23-44

4 years ago

2.7.23-41

4 years ago

2.7.23-42

4 years ago

2.7.23-40

4 years ago

2.7.23-38

4 years ago

2.7.23-39

4 years ago

2.7.23-36

4 years ago

2.7.23-37

4 years ago

2.7.23-34

4 years ago

2.7.23-35

4 years ago

2.7.23-32

4 years ago

2.7.23-31

4 years ago

2.7.23-30

4 years ago

2.7.23-27

4 years ago

2.7.23-28

4 years ago

2.7.23-25

4 years ago

2.7.23-26

4 years ago

2.7.23-24

4 years ago

2.7.23-21

4 years ago

2.7.23-20

4 years ago

2.7.23-18

4 years ago

2.7.23-19

4 years ago

2.7.23-29

4 years ago

2.7.23-16

4 years ago

2.7.23-17

4 years ago

2.7.23-15

4 years ago

2.7.23-14

4 years ago

2.7.23-12

4 years ago

2.7.23-13

4 years ago

2.7.23-10

4 years ago

2.7.23-11

4 years ago

2.7.23-9

4 years ago

2.7.23-8

4 years ago

2.7.23-7

4 years ago

2.7.23-6

4 years ago

2.7.23-4

4 years ago

2.7.23-3

4 years ago

2.7.23-2

4 years ago

2.7.23-1

4 years ago

2.7.23

4 years ago