node-red-contrib-smartcontracttx 1.1.6

Allows to run transactions on Ethereum based blockchains from within Node RED

npm install node-red-contrib-smartcontracttx

Allows to run transactions on Ethereum based blockchains from within Node RED

Call methods or run transactions using rpcUrl and ABI of existing contract. Allows OffChain DID/VP signing and verification.

npm npm CO2OffsetCode QualityCircleCIFOSSA Status

Installation

Install using Node-RED Package Manager (Palett).

Input - msg.payload

OnChain - Transaction/Retrieve

In order to call a method of a SmartContract specify a JSON in msg.payload containing the method name as method and all required arguments in an array as args.

{
  "method":"transfer",
  "args":["0x6B342cE1cb8671DDeeC57B62D78EB9333898d7da",20]
}

OffChain - Present

To present a set of information (Object) signed to another party DID-VPs are used. In this case msg.payload must contain presentTo with the recipients publicKey (not address - see here ) and presentation with the Data to crypt and sign.

{
  "presentTo":"0x02eb74c1b28754e079ac138f0d1d73c0b9d82ba2a14ea3146f7f540e841ee43679",
  "presentation":{
    'Hello':'World',
    'TimeStamp': 1641166171599
  }
}

If presentTo is not specified the presentation itself will just be signed and not encrypted.

Injection of unsecure values

If configuration option Allow Insecure Inject is set additional values might be specified in input msg.payload and will overwrite configured values:

{
  ...
  "privateKey":"0x12356....",
  "contract":"0x123456...",
  "abi": [...],
  "rpcUrl": "https://integration.corrently.io/",
  ...
}

In case no privateKey is specified in either input msg.payload or configuration, a new privateKey gets generated.

Output - msg.payload

For background compatibility all results are returned on Output[0]

Output[1] - OnChain Output. Returns results from method calls or transactions.

Output[2] - OffChain Output (JWT). Encrypted DID to be forwarded to other recipient.

Output[3] - OffChain Output. Presentations received and decoded.

Cloudwallet support

Implementation allows to use CloudWallet to persist received presentations/credentials or digital IDs via https://www.npmjs.com/package/cloudwallet

Usage as Module (no Node-RED)

You might use this module without having Node-RED available. However this requires to emulate some of the stuff Node-RED typically provides.

Installation

npm i --save node-red-contrib-smartcontracttx

Hello World (DID)

const SmartContractTX = require("node-red-contrib-smartcontracttx");

const app = async function() {
  const instanceAlice = new SmartContractTX();
  let msgAlice = {
    payload: {
        presentation: {
          'Hallo':'Welt'
        }
    }
  }

  // We need to do something with DIDComms (Message Alice wants to send) ...
  instanceAlice.setSender(async function(msgs) {
      // As soon as JWT got generated (Alice wants to send) - we forward to a new Bob
      const instanceBob = new SmartContractTX();
      let msgBob = msgs[2]; // Alice Output is [2] as we want the JWT
      console.log('Message from Alice to Bob',msgBob);
      // If Bob received a message he sends via output[3] to internal processes...
      instanceBob.setSender(async function(msgs) {
          console.log('Bob DID',msgs[3]);
      });
      await instanceBob.input(msgBob);
      console.log('End');
  });

  // Now we are ready to send Message from Alice
  await instanceAlice.input(msgAlice);
}

app();

Tutorials / Usecases

Maintainer / Imprint

STROMDAO GmbH
Gerhard Weiser Ring 29
69256 Mauer
Germany

+49 6226 968 009 0

[email protected]

Handelsregister: HRB 728691 (Amtsgericht Mannheim)

Project Website: https://co2offset.io/

LICENSE

Apache-2.0

Node Info

Version: 1.1.6
Updated 5 months, 3 weeks ago
License: Apache-2.0
Rating: 3.0 2

Actions

Rate:

Downloads

8 in the last week

Nodes

  • SmartContract
  • DLTConnection
  • Contract
  • Resolver

Keywords

  • nodered
  • node-red
  • contrib
  • ethereum
  • blockchain
  • transaction
  • smartcontract

Maintainers