wallet-notify

0.3.1 • Public • Published

wallet-notify

Set of tools to create and process wallet notifications

npm

yarn add wallet-notify

Notification format

{
  text: "Hello, I'm a wallet notification!", // <-- required
  thumbnailUrl: "https://me.com/my-logo.gif",
}

// OR

{
  text: "Hello, I'm a wallet notification. Click to go to my website.", // <-- required
  thumbnailUrl: "https://me.com/my-logo.gif",
  actionUrl: "https://me.com/do-that-thing"
}

// OR

{
  text: 'Hello, I’m a wallet notification. Click to buy crypto kitty', // <-- required
  thumbnailUrl: "https://me.com/my-logo.gif",
  actionTx: {
    to: '0x...', // <-- required
    amount: 0,
    data: '0xdeadbeef'
  }
}

// OR

{
  t: 'Hello, I’m a short version notation notification',
  tu: 'http://smal.co/pic.gif'
  au: 'http://smal.co'
}

Send notification

import WalletNotify from 'wallet-notify'

const notification = {
  text: 'Hello World',
  thumbnailUrl: 'https://www.publicdomainpictures.net/pictures/200000/velka/unicorn-icon.jpg',
  actionUrl: 'https://ethwaterloo.com'
}

const tx = await WalletNotify.send({
  notification
  to: addressOrAddressArray,
  web3: web3,
  gasPrice: gasPrice,
  gasLimit: gasLimit,
})

// OR

const data = WalletNotify.encode(notification)
const tx = await provider.transactionSend({
  ...,
  data
})

Receive notification

import WalletNotify from 'wallet-notify'

// ... listen to incoming transactions

const notification = WalletNotify.decode(tx)
if (notification) {
  // render as a notification
}
// render as a transaction

Readme

Keywords

none

Package Sidebar

Install

npm i wallet-notify

Weekly Downloads

0

Version

0.3.1

License

MIT

Unpacked Size

7.68 kB

Total Files

5

Last publish

Collaborators

  • rpavlovs