Skip to content

Commit c7d4395

Browse files
Update README.md
1 parent e5a715a commit c7d4395

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,13 @@ let fileBuffer = result.fileBuf;
4343
Below is a simple example. For a more complete React.js [file upload example](https://github.com/simpleledger/SimpleToken.cash/blob/master/src/UploadDialog.js) visit [SimpleToken.cash website](https://simpletoken.cash)
4444

4545
```javascript
46-
const bfp = require('bitcoinfiles').bfp;
47-
const network = require('bitcoinfiles').network;
46+
const Bfp = require('bitcoinfiles').bfp;
47+
const Network = require('bitcoinfiles').network;
4848
const BITBOX = require('bitcoinfiles').bitbox;
4949

50+
const bfp = new Bfp();
51+
const network = new Network();
52+
5053
// 1 - get a file and file metadata somehow
5154
const someFileBuffer = new Buffer.from('aabbccddeeff', 'hex');
5255
const fileName = 'a test file';
@@ -66,7 +69,7 @@ let config = {
6669
fileUri: null,
6770
chunkData: null // chunk not needed for cost estimate stage
6871
};
69-
let uploadCost = bfp.calculateFileUploadCost(fileSize, config);
72+
let uploadCost = Bfp.calculateFileUploadCost(fileSize, config);
7073
console.log(uploadCost);
7174

7275
// 3 - create a funding transaction
@@ -75,9 +78,10 @@ let fundingWif = 'KzcuA9xnDRrb9cPh29N7EQbBhQQLMWtcrDwKbEMoahmwBNACNRfa'
7578

7679
// 4 - Make sure address above is funded with the amount equal to the uploadCost
7780
let fundingUtxo;
81+
7882
(async function(){
79-
let txos = await network.getUtxoWithRetry(fundingAddress);
80-
fundingUtxo = txos[txos.length-1]; // UTXOs are sorted small to large, so grab biggest one to be conservative.
83+
let txo = await network.getUtxoWithRetry(fundingAddress);
84+
8185
console.log('got funding Utxo.')
8286
})();
8387

@@ -114,4 +118,4 @@ let metadata;
114118
// prev_sha256: '',
115119
// ext_uri: '' }
116120

117-
```
121+
```

0 commit comments

Comments
 (0)