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

eve-js

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eve-js

A simple wrapper for using ethereum in the browser

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

eve-js

Build apps with ethereum in the browser. A collection of helpers to build more readable webapps with ethereum.

Intended for use alongside browser plugins like (the amazing) Metamask that load web3 onto the window.

Methods

parseProtocolUrl(url)

Build a raw ethereum transaction by parsing an ethereum "protocol url" and query, according to this discussion here.

The transaction is encoded like ethereum:[to_address]?[params,...]

Put value, and gas in params to pass these options into the transaction, along with (optionally) one of the following to encode a function call

  • function: a string of the raw function signature like functionImCalling(arg_1_value, arg_2_value)

  • fn: the name of the function you'd like to call (as specified in the Contract's ABI), and a query-encoded abi like

    fn=functionImCalling&
    input.arg_1.type=string&
    input.arg_1=arg_1_value&
    input.arg_2.type=address&
    input.arg_2=arg_2_value
    
  • data: encoded bytecode of the transaction inputs as described here

buildAPIWithABI(abi)

Build an associative array (object) of javascript functions to call a Contract's functions from your application code. Call the function by name with the normal arguments from the Contract, a parameter options to optionally configure from, value, and gas, and a callback for the web3 provider.

eve = require 'eve-js'

# A hypothetical ethereum call that pays an
# invoice keyed off a unique string.

my_abi = [{
    constant: false,
    inputs: [{
        name: "purchaser",
        type: "string"}
    ],
    name: "payInvoice",
    outputs: [],
    payable: true,
    type: "function"
}]

# Build a function to use in your code
{payInvoice} = eve.buildAPIWithABI my_abi

# now call the function like...
invoice_address = 'my_invoice_address'
purchaser_key = window.user.my_unique_key
options = {}
payInvoice invoice_address, purchaser_key, options, (err, txid) ->
    # handle response here...

The functions will be called by passing them to window.web3, like Metamask provides.

execWithABI(abi, address, fn, args..., options, cb)

Call a function by name from a raw ABI and a Contract address. Optionally configure from, value, and to in options. Using the same example from above...

eve.execWithABI my_abi, invoice_address, 'PayInvoice', purchaser_key, {}, (err, txid) ->
    # handle response here...

send({to, from, gas, value}, cb)

Convenience function to send ether from raw transaction json. from and gas are optional.

eve = require 'eve-js'

bill_payer = '0x0'

my_accounts = {
    utilities: '0x0'
    dinner: '0x0'
    girlfriend: '0x0'
}

sendTransaction = (reason) ->
    eve.send {to: bill_payer, from: my_accounts[reason], value: 1000000000000000}

Keywords

FAQs

Package last updated on 26 Mar 2017

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