npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

iota-lambda-shim

v0.0.3

Published

A simple shim that offloads IOTA PoW to AWS Lambda Functions

Downloads

8

Readme

IOTA Lambda

offload your POW to AWS lambda!

Purpose

This is an example project of using AWS lambda to perform the attachToTangle command without having to run it locally or run a full node. Using AWS Lambda (or any FaaS) can allow for infinite scaling without having to manage underlying servers. Using this method, you could run a fleet of IOTA devices, pointing to a public full node that doesn't support attachToTangle, and handle the POW yourself! Magic!

Getting Started

Prerequisites

Sorry, but this one needs a few disparate bits and pieces to get it working:

  • AWS account, with credentials in ~/.aws/credentials, or in your current env

  • serverless (installed with docker below), but you need to have a basic understanding of how serverless and cloudformation works.

    sidebar: We probably don't need Serverless for this project. My first iteration was to use ApiGateway and set up an IOTA proxy based on this: https://github.com/TimSamshuijzen/iotaproxy. However, ApiGateway has a hard timeout limit of 30s, which is fine for every iota command except for attachToTangle.

  • Docker & docker-compose we use docker to build the native npm modules for the exact version of Amazon Linux that AWS Lambda runs internally.

  • node and yarn

Deployment

  1. build the containers and login to the docker container
#build the docker container
$ ./_enter_docker.sh build

#run the container
$ ./_enter_docker.sh
  1. deploy the lambda function. You may want to change the region in sls_iotaproxy/serverless.yml
  docker$ ./_deploy.sh  

Wait for serverless to deploy, make a cup of tea maybe. It's a known fact that deployments take longer if you sit there watching them.

Installation

Once you have successfully deployed your function, you can use it to perform your PoW.

Install the iota-lambda-shim package:

yarn add iota-lambda-shim

Make a note of your provider (this can be a public full node that doesn't support AttachToTangle) the functionName. Put them in a config file like so:

config.js

module.exports = {
  provider: 'http://5.9.149.169:14265',
  functionName: 'IotaProxy-dev-attHandler',
}

Basic Usage:

/*iota library */
const IOTA = require('iota.lib.js');
const { provider, functionName } = require('./config');

//Please don't ever use this seed for anything
const seed = "UFLKWXVHYTPDBAOJS9CQMGNRZEI";
const iota = new IOTA({
  provider,
});

/* set up AWS config to refer to our lambda */
const AWS = require('aws-sdk');
const lambda = new AWS.Lambda({
  region: 'ap-southeast-2' //I come from a land down under
});

const IotaLambdaShim = require('iota-lambda-shim');

// Patch the current IOTA instance
IotaLambdaShim({iota, lambda, functionName});

//Now do whatever you want with the IOTA js api.

Feel free to use this, or let it inspire you to build something else. PRs welcome :)

Let me know if you want to build something together. Feel free to message me at my github email.

Tips are welcome 🙌🙌🙌

ETQINORRZDFPMTXUIXHTWFWZXGLNZM9O9CSYXITH9KLTKRHZIQ9WZFBPSFOQRYQCB9USIMAOBVZNMIH99C9AHFZNQZ

Handy Snippets

#invoke local AttHandler:
serverless invoke local -f attHandler --path ./testAttachToTangle.json

#getTrytes
# curl http://localhost:14265 \
# use this to just get an example of valid trytes
curl http://node06.iotatoken.nl:14265 \
  -X POST \
  -H 'Content-Type: application/json' \
  -H 'X-IOTA-API-Version: 1' \
  -d '{"command": "getTrytes", "hashes": ["9EDOGCRGAHHYXHWMFYCBXMWUPWZCTBUYYJOBP9RESITGUZBGVWQBNFDN9WMQKSMYYSNROWBXGDUZZ9999"]}'