![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
bitcoin-computer
Advanced tools
BitcoinComputer is a Javascript library for running smart contracts on Bitcoin.
We give a few examples of smart contracts. See bitcoincomputer.io for more documentation.
A non-fungible token is a Javascript class with some state. It has a constructor to initialize the state, a function to update the state, and a function to send the token to another user. The _owners
controlls who may update the object. For more information see the docs.
class Token {
constructor(state) {
this.state = state
}
setState(state) {
this.state = state
}
send(to) {
this._owners = [to]
}
}
You can deploy a token and send it to another user by running the following code.
// create Bitcoin Computer wallet
const computer = new Computer({
seed: 'replace this seed', // your BIP39 seed
chain: 'BSV' // BSV or BCH
})
// deploy the smart contract
const token = await computer.new(Token, ['some state'])
// send token to another user
const publicKey = '03223d...46d06c8dfe'
await token.send(publicKey)
A fungible token consists of several instances of the Coin
class. A coin object can hold a number of tokens. A coin can be split into two coins using the send
function and the smart contract guarantees that no new tokens are created.
class Coin {
constructor(supply, to) {
this.tokens = supply
this._owners = [to]
}
send(amount, to) {
if(this.tokens < amount) throw new Error('insufficient funds')
this.tokens -= amount
return new Coin(amount, to)
}
}
While Bitcoin Computer can create many variants of custom tokens, it can do much more than that. It's a tool to make web application development easy. Below we show how a chat can be built on the Bitcoin Computer. The smart contract persists the objects and thus no separate database is needed to build an application.
class Chat {
constructor() {
this.messages = []
}
invite(publicKey) {
this._owners.push(publicKey)
}
post(messages) {
this.messages.push(message)
}
}
The easiest way to get started is to run the tests. In an empty directory run
git clone git@github.com:bitcoin-computer/computer.git
cd computer
npm install
npm test
If you get an error "Insuffienct balance in <your address>" send free testnet coins to <your address> as explained in Fund Your Computer below.
In an empty directory run npm init -y && npm i -s bitcoin-computer
. Create file index.mjs
as shown below.
import { Computer } from 'bitcoin-computer'
// the smart contract
class Counter {
constructor() { this.n = 0 }
inc() { this.n += 1 }
}
// run the smart contract
;(async () => {
const seed = 'replace this seed'
const chain = 'BSV'
const network = 'testnet'
const computer = new Computer({ seed, chain, network })
const counter = await computer.new(Counter, [])
await counter.inc()
console.log(counter)
})()
Run the code using
node --experimental-modules index.mjs
If you get an error "Insuffienct funds in <your address>" have a look at the secion Fund Your Computer below. Run the code again after funding the wallet and you will see:
Counter {
n: 1,
_id: '83553f27c9e4651323f1ebb...',
_rev: '290923708ca56ea448dd67...'
}
Create file .babelrc
{
"presets": [ "@babel/preset-env" ],
"plugins": [ [ "@babel/transform-runtime" ] ]
}
Create file index.html
<html>
<body>
<div id='el'></div>
<script src="./index.js"></script>
</body>
</html>
Create file index.js
import { Computer } from 'bitcoin-computer'
class Counter {
constructor() { this.n = 0 }
inc() { this.n += 1 }
}
;(async () => {
const seed = 'replace this seed'
const chain = 'BSV'
const network = 'testnet'
const computer = new Computer({ seed, chain, network })
const counter = await computer.new(Counter, [])
document.getElementById("el").innerHTML = `Counter is ${counter.n}`
await counter.inc()
document.getElementById("el").innerHTML = `Counter is ${counter.n}`
})()
Run the following in an empty directory
npm init -y
npm i -s bitcoin-computer
npm i -g parcel-bundler
npm i -s @babel/runtime
npm i -d @babel/plugin-transform-runtime
parcel index.html
Open your browser at http://localhost:1234
. See the instructions for how to configure your own seed phrase and how to fund the computer in the sections below.
By default the bitcoin computer object uses the pass phrase "replace this seed" to initialize the wallet. If you want to use your own seed phrase, replace the string "replace this seed" with any bip39 compatible seed phrase or generate a new one here.
If you get an error message "Insufficient balance in address <your_address>" you need to fund the wallet inside the computer object. You can get free testnet coins from a Bitcoin SV faucet or a Bitcoin Cash Faucet and send them to <your_address>.
You can find more information in the Bitcoin Computer Docs
If you have any issues ask a question in the Telegram Group or create an issue on Github.
Code it licenced under Attribution-NoDerivs 3.0 Unported. You are free to: Share, copy, and redistribute the material in any medium or format for any purpose, even commercially under the following terms:
This is a human-readable summary of (and not a substitute for) the license.
We are in beta to indicate that there are known security vulnerabilities. Our priority is to fix all security related issues. Once done we will remove the beta tag and start a bug bounty program to find all remaining bugs.
import { Computer } from 'bitcoin-computer
instead of import Computer from 'bitcoin-computer
path
option to the empty string when creating a computer object.FAQs
Lightweight Smart Contracts for Bitcoin and Litecoin
The npm package bitcoin-computer receives a total of 21 weekly downloads. As such, bitcoin-computer popularity was classified as not popular.
We found that bitcoin-computer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.