0.0.2 • Published 1 year ago

token-mesh v0.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

Token-Mesh

token-mesh.com

The purpose of the mesh is to provide seamless flow of token value from one chain to another.

Other systems often use insecure, unreliable mechanisms to receive locking transactions and to output unlocking transactions. Each lock should correspond to exactly one unlock, and must take place in near real time.

The system should be able to handle the very tiniest amount of value possible, so swaps should take place between BSV and USDC on Solana, which can then be sent to any exchange that supports Solana.

It may also be ideal to issue a BSV token on Solana and have that become trade-able on the Solana-based decentralized exchange programs, then offer a swap directly from BSV native token to BSV on Solana.

All deposits shall be received directly via the Payment Protocol so that payments are exactly correct every time.

import { Swap, Lock, Unlock } from 'token-mesh'

import { loadWallet } from 'wallet-bot'

export async function main() {

  const wallet = await loadWallet()

  const swap: Swap = await Swap.Create({

    lock: {
      chain: 'BSV',
      currency: 'BSV'
    },

    unlock: {
      chain: 'SOL',
      currency: 'USDC',
      address: wallet.getAddress({ currency: 'USDC', chain: 'SOL' }),
      value: 0.001
    }
    
  })

  swap.on('lock.detected', (lock: Lock) => {

    console.log('valid lock transaction detected in the mempool', {
      satoshis: lock.value,
    })

  })

  // wallet.pay() should trigger 'lock.detected' event on the swap
  const result = await wallet.pay({ uri: swap.payment_request_uri })
 

  swap.on('lock.confirmed', (lock: Lock) => {

    console.log('lock confirmed, system will be sending coins soon')      

  })

  swap.on('unlock.detected', (unlock: Unlock) => {

    console.log('${unlock.value} ${unlock.currency} unlocked on ${unlock.chain}')

  })

  swap.on('unlock.confirmed', (unlock: Unlock) => {
  
  	console.log('Unlock confirmed, likely funds may be used soon on centralized exchanges')

  })

}

main()

With scrypt smart contracts and solana smart contracts the entire transaction can occur in blockchain escrow, where price negociations occur and all transaction data is embedded.

On bitcoin deposits shall be made to a contract that locks coins for a specified period of time, as wells as specifying the desired token unlocking script and value for the corresponding chain and currency. Before the locking script may be unlocked by its creator the swap service has an opportunity to provide the swap txid on solana into the bitcoin contract, releasing the funds to any address they choose. Only the token mesh public key may be used to provide the solana txid/signatures and unlock the satoshis contained in the contract.

0.0.2

1 year ago

0.0.1

1 year ago