GetScatter / ScatterWebExtension

Extension that allows you to sign transactions with your private keys securely from within the browser without ever exposing them.
MIT License
366 stars 127 forks source link

EOSJS and scatter #132

Closed bachvtuan closed 6 years ago

bachvtuan commented 6 years ago

I tried to integrate scatter with eosjs to make a tweet on decentwitter Here is my code

document.addEventListener('scatterLoaded', scatterExtension => {

    const scatter = window.scatter;

    window.scatter = null;

    scatter.getIdentity( ).then(identity => {

        var network = {
            blockchain: 'eos',
            host: 'nodes.get-scatter.com',
            port: 443,
            chainId: 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906'
        };

        const eosOptions =  {}

        const eos = scatter.eos( network, Eos, { chainId: network.chainId },"https");

        eos.contract('decentwitter').then(contract => {
           contract.tweet("hello");
        });

    }).catch(error => {
        //...
    });
})

And I get an error:

{type: "account_missing", message: "Missing required accounts, repull the identity", code: 402, isError: true}

Can you help how to solve it ?

bachvtuan commented 6 years ago

60

nsjames commented 6 years ago

You aren't requesting an EOS account from getIdentity. You'll need to do that, and you might need to manually pass it in as an authorization:[] option for the contract action.