New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

eosio-uri

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eosio-uri

`eosio:` uri encoder and decoder

  • 0.0.5
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-77.78%
Maintainers
2
Weekly downloads
 
Created
Source

eosio-uri

URI protocol for facilitating signing of EOSIO transactions.

Example Data

Sample Data

{
    callback: 'https://dapp.greymass.com',
    actions: [{
        account: 'eosio.token',
        name: 'transfer',
        authorization: [{ actor: 'teamgreymass', permission: 'active' }],
        data: {
            from: 'teamgreymass',
            to: 'dapp',
            quantity: '42.0000 EOS',
            memo: 'share and enjoy!',
        }
    }]
}

URI Generated

eosio:23NcfRWj7pN3ea4b58SDtkHKMnPNccjPcmPnRgK4psydL5gYLrVbAvpe2J5KbJTA9kVeqfTxPx29ykwJKZLo3o1phYrxwCqjUBotHGwFAiFUm7wyCNjV2TMVy

Example Code

const util = require('util')
const zlib = require('zlib')
const eosjs = require('eosjs')

const { SigningRequest } = require("eosio-uri")

const textEncoder = new util.TextEncoder()
const textDecoder = new util.TextDecoder()

// create an instances of eosjs for rpc calls
const rpc = Eos({
    httpEndpoint: 'https://eos.greymass.com'
});

// opts for the signing request
const opts = {
    // string encoder
    textEncoder,
    // string decoder
    textDecoder,
    // string compression
    zlib: {
        deflateRaw: (data) => {
            return new Uint8Array(zlib.deflateRawSync(Buffer.from(data)))
        },
        inflateRaw: (data) => {
            return new Uint8Array(zlib.inflateRawSync(Buffer.from(data)))
        },
    },
    // provider to retrieve contract abi
    abiProvider: {
        getAbi: async (account) => {
            return (await rpc.get_abi(account)).abi
        }
    }
}

async function main() {
    /*
      creating a signing request

      parameters (all optional):
          - action: object, single action
          - actions: array, multiple actions
          - transaction: object, whole transaction
          - chainId: string, either the chainId or a named string (predefined, EOS|TELOS)
          - broadcast: boolean, whether or not to broadcast this transaction after signing
          - callback: string|object | either a URL callback or object ({url: string, background: boolean})
    */
    let req = await SigningRequest.create({
        callback: 'https://dapp.greymass.com',
        actions: [{
            account: 'eosio.token',
            name: 'transfer',
            authorization: [{ actor: 'teamgreymass', permission: 'active' }],
            data: {
                from: 'teamgreymass',
                to: 'dapp',
                quantity: '42.0000 EOS',
                memo: 'share and enjoy!',
            }
        }]
    }, opts)

    // encode signing request as string
    let uri = req.encode()
    console.log(`URI: ${ uri }`)

    // reinterpret from encoded string
    req = SigningRequest.from(uri, opts)
    console.log(`Actions\n${ util.inspect(await req.getActions()) }`)
    console.log(`Transaction\n${ util.inspect(req.getTransaction()) }`)
    console.log(`Callback\n${ util.inspect(req.getCallback()) }`)
}

main().catch(console.error)

FAQs

Package last updated on 28 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc