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

@acryl/acryl-transactions

v3.16.8

Published

Build and sign(multi-sign) transactions for Acryl blockchain.

Downloads

19

Readme

acryl-transactions

Using this library you can easily create and sign transactions for Acryl blockchain. It also allows you to multi-sign existing transactions or create them without signature at all.

This library is a set of transaction constructing functions:

Check full documentation on GitHub Pages.

Transactions

The idea is really simple - you create transaction and sign it from a minimal set of required params. If you want to create Transfer transaction the minimum you need to provide is amount and recipient as defined in Transfer params:


const { transfer } = require('@acryl/acryl-transactions')
const seed = 'some example seed phrase'
const signedTranserTx = transfer({ 
  amount: 1,
  recipient: '3EKhM51MGZrq8FTnvKoTg95srTiC2Votx1B',
  //Timestamp is optional but it was overrided, in case timestamp is not provided it will fallback to Date.now(). You can set any oftional params yourself. go check full docs
  timestamp: 1536917842558 
}, seed)

// or using alias

const signedTranserTx = transfer({ 
  amount: 1,
  recipient: 'alias:A:aliasForMyAddress'
}, seed)

Output will be a signed transfer transaction:

{
  id: '8NrUwgKRCMFbUbqXKQAHkGnspmWHEjKUSi5opEC6Havq',
  type: 4,
  version: 2,
  recipient: '3EKhM51MGZrq8FTnvKoTg95srTiC2Votx1B',
  attachment: undefined,
  feeAssetId: undefined,
  assetId: undefined,
  amount: 1,
  fee: 100000,
  senderPublicKey: '4MUrTiAwkVhRdkUj2Ya4LZbM7tGgd4sinLsGRZBvBvNa',
  timestamp: 1536917842558,
  proofs: [
    '25kyX6HGjS3rkPTJRj5NVH6LLuZe6SzCzFtoJ8GDkojY9U5oPfVrnwBgrCHXZicfsmLthPUjTrfT9TQL2ciYrPGE'
  ]
}

You can also create transaction, but not sign it:

const unsignedTransferTx = transfer({ 
  amount: 1,
  recipient: '3EKhM51MGZrq8FTnvKoTg95srTiC2Votx1B',
  //senderPublicKey is required if you omit seed
  senderPublicKey: '4MUrTiAwkVhRdkUj2Ya4LZbM7tGgd4sinLsGRZBvBvNa' 
})

Now you are able to POST it to Acryl API or store for future purpose or you can add another signature from other party:

const otherPartySeed = 'other party seed phrase'
const transferSignedWithTwoParties = transfer(signedTranserTx, seed)

So now there are two proofs:

{
  id: '8NrUwgKRCMFbUbqXKQAHkGnspmWHEjKUSi5opEC6Havq',
  type: 4,
  version: 2,
  recipient: '3EKhM51MGZrq8FTnvKoTg95srTiC2Votx1B',
  attachment: undefined,
  feeAssetId: undefined,
  assetId: undefined,
  amount: 1,
  fee: 100000,
  senderPublicKey: '4MUrTiAwkVhRdkUj2Ya4LZbM7tGgd4sinLsGRZBvBvNa',
  timestamp: 1536917842558,
  proofs: [
    '25kyX6HGjS3rkPTJRj5NVH6LLuZe6SzCzFtoJ8GDkojY9U5oPfVrnwBgrCHXZicfsmLthPUjTrfT9TQL2ciYrPGE',
    'CM9emPzpe6Ram7ZxcYax6s7Hkw6698wXCMPSckveFAS2Yh9vqJpy1X9nL7p4RKgU3UEa8c9RGXfUK6mFFq4dL9z'
  ]
}

Broadcast

To send transaction you can use either node REST API or broadcast helper function:

const {broadcast} =  require('@acryl/acryl-transactions');
const nodeUrl = 'https://nodes.acrylplatform.com';

broadcast(signedTx, nodeUrl).then(resp => console.log(resp))

Alias

Simlpe alias creation example:

const { alias } = require('@acryl/acryl-transactions')
const { broadcast } =  require('@acryl/acryl-transactions');
const nodeUrl = 'https://nodes.acrylplatform.com';
const seed = 'some example seed phrase'

const signedAliasTx = alias({
    alias: "someAlias"
    //Timestamp is optional but it was overrided, in case timestamp is not provided it will fallback to Date.now(). You can set any oftional params yourself. go check full docs
  timestamp: 1536917842558 
}, seed);

broadcast(signedAliasTx, nodeUrl).then(resp => console.log(resp))

You can send tx to any acryl node you like:. E.g.:

  • https://nodestestnet.acrylplatform.com - Acryl TESTNET nodes hosted by AcrylPlatform
  • https://nodes.acrylplatform.com - Acryl MAINNET nodes hosted by AcrylPlatform

Important!!!

Most transactions require chainId as parameter, e.g: IBurnParams. By default chainId is 'A', which means MAINNET. To make transaction in TESTNET be sure to pass chainId if it is present in params interface and then send it to TESTNET node