Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@matterpool/bitcoinfiles-js

Package Overview
Dependencies
Maintainers
3
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@matterpool/bitcoinfiles-js

BitcoinFiles JS

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
3
Weekly downloads
 
Created
Source

BitcoinFiles JS

Upload large files directly to Bitcoin.

Installation

npm install @matterpool/bitcoinfiles-js

JS Usage

Uploading and paying for a file

const bitcoinfiles = require('@matterpool/bitcoinfiles-js');

const workspaceId = '<insert-workspace-id>';
const file = new File(['foo', 'bar'], 'foobar.txt');
const formData = new FormData();
formData.append('file', file);

const upload = bitcoinfiles.upload(formData, workspaceId);

const paymentAddress = upload.payment_address;
const paymentSatoshis = upload.payment_satoshis;

// use paymentAddress and paymentSatoshis to pay for the file
// you can use any bitcoin wallet to pay for bitcoin files

const rawtx = '....'
const payment = await bitcoinfiles.pay(rawtx);
// save the transaction id of the file to download it later
const txid = payment.result[0].txid 

Downloading a File

const txid = '8f7090ec72a692e7bb893a3fd4ef1e508c655a284a5b736b3cc7c63649748562'
const file = await bitcoinfiles.download(txid);

API Usage

Upload

Request

POST https://api.bitcoinfiles.org?tag=<workspace-id>
Content-Type: multipart/form-data
Body:
  file: <file-contents>

Response

{
    payment_address: '18Qi1rXJSLDLUYDZVkRT3ZdyB3E9eZamY2',
    payment_satoshis: 2833,
    session_tag: '<workspace-id>',
    location: '<file-cdn-url>'
}

Pay

To pay for a file, pay payment_address the amount of payment_satoshis. You can pay for multiple files at once in the same transaction

Request

POST https://api.bitcoinfiles.org/pay
Content-Type: application/json
Body:
{
  rawtx: '<raw-transaction-hex>'
}

Response

{
    errors: [],
    status: 200,
    result: [{
        txid: 'f7a3e5838a134a78b6a5033aa928efb7849be6212307b9b9eed3c738ea470bc2',
        session_tag: '<workspace-id>',
        fileurl: '<file-cdn-url>',
        payment_address: '18Qi1rXJSLDLUYDZVkRT3ZdyB3E9eZamY2',
        payment_sats_needed: 2833,
        filesize: 2775,
        created_time: 1602905335,
        filename: '<filename>',
    }]
}

Download

You can download a file by using it's transaction id. This link can be used in html tags like <img>, <video> or <audio>

Request

GET https://media.bitcoinfiles.org/[txid]

FAQs

Package last updated on 17 Oct 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc