scatter-ts
TypeScript icon, indicating that this package has built-in type declarations

0.1.9 • Public • Published

Scatter TS (Typescript)

Install

$ npm install scatter-ts

Quickstart

import { ScatterJS, ScatterEOS } from 'scatter-ts';
import { JsonRpc, Api } from 'eosjs';
import fetch from 'node-fetch';

ScatterJS.plugins( new ScatterEOS() );

const network = ScatterJS.Network.fromJson({
    blockchain: 'eos',
    chainId: 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906',
    host: 'eos.eosn.io',
    port: 443,
    protocol: 'https'
});
const rpc = new JsonRpc(network.fullhost(), { fetch });

ScatterJS.connect('YourAppName', {network}).then(connected => {
    if(!connected) return console.error('no scatter');

    const eos = ScatterJS.eos(network, Api, { rpc });

    ScatterJS.login().then(id => {
        if(!id) return console.error('no identity');
        const account = ScatterJS.account('eos');

        eos.transact({
            actions: [{
                account: 'eosio.token',
                name: 'transfer',
                authorization: [{
                    actor: account.name,
                    permission: account.authority,
                }],
                data: {
                    from: account.name,
                    to: 'safetransfer',
                    quantity: '0.0001 EOS',
                    memo: account.name,
                },
            }]
        }, {
            blocksBehind: 3,
            expireSeconds: 30,
        }).then(res => {
            console.log('sent: ', res);
        }).catch(err => {
            console.error('error: ', err);
        });
    });
});

Readme

Keywords

none

Package Sidebar

Install

npm i scatter-ts

Weekly Downloads

388

Version

0.1.9

License

MIT

Unpacked Size

163 kB

Total Files

35

Last publish

Collaborators

  • deniscarriere