sCrypt for Ethereum Developers
Smart contracts on Bitcoin vs Ethereum
Bitcoin and Ethereum are both layer-1 blockchains with fully programmable smart contracts. However, their designs are fundamentally different.
Ethereum is a global state machine, whose state consists of all smart contracts deployed on it. Each transaction is an input to the state machine, transitioning it to the next state according to the rules defined in the smart contract the transaction calls. The design imposes severe limitations on scalability, since transactions must be sequentially processed due to potential race conditions.
In Bitcoin, transaction processing is independent of each other since all information needed is localized. There is no shared global state. Bitcoin is maximally parallelizable by design.
Detailed side-by-side comparison can be found here, which is concisely summarized below.
Ethereum | Bitcoin | |
---|---|---|
Execution Environment | Ethereum Virtual Machine (EVM) | Bitcoin Virtual Machine (BVM) |
Model | Account | UTXO |
Transaction Fee | $1-10 | $0.00001 |
Transactions Per Second | 15 | 3000+ |
Transaction Processing | Sequential | Parallel |
Scalability | Vertical | Horizontal |
Paradigm | Impure | Pure |
Miner Extractable Value (MEV) | Yes | No |
Smart contract development on Bitcoin vs Ethereum
In addition to an unboundedly scalable foundation, Bitcoin also offers a superior smart cotnract developer experience.
The table below shows a comparison of popular Ethereum development tools and their counterparts in the Bitcoin ecosystem.
There are two noticeable differences.
- Bitcoin smart contract is written in TypeScript, one of the most popular programming languages tens of millions of Web2 developers are already familiar with. They do not have to learn a new niche programming language like Solidity, placing a high barrier to entry. They can reuse their favorite tools, such as Visual Studio Code, WebStorm, and NPM.
- Ethereum's development tools are fragmented. They are developed by different entities, who are often competitors. There are disincentives to make them more interoperable, thus they don't communicate with each other well. By contrast, sCrypt takes a more holistic and systematic approach. It builds a unified full-stack platform that encompasses most tools, from programming language, to framework/libraries. Developed synergistically, they are fully compatible with each other, greatly simplifying and streamlining the development process.
Ethereum | Bitcoin | |
---|---|---|
Programming Language | Solidity | sCrypt DSL |
Framework | Hardhat / Truffle | The sCrypt CLI |
Libraries | Web3.js / Ethers.js | scrypt-ts |
Developer Platform | Alchemy / Infura | sCrypt |
IDE | Remix1 | Visual Studio Code |
Wallet | MetaMask | Yours |
Block Explorer | Etherscan | WhatsOnChain |
Example Code
Let's compare a Counter
smart contract between Solidity and sCrypt.
pragma solidity >=0.7.0 <0.9.0;
contract Counter {
int private count;
constructor(int _initialCount) {
count = _initialCount;
}
function incrementCounter() public {
count += 1;
}
function getCount() public view returns (int) {
return count;
}
}
class Counter extends SmartContract {
@prop(true)
count: bigint
constructor(count: bigint) {
super(...arguments)
this.count = count
}
@method()
public incremenCounter() {
this.count++
assert(hash256(this.buildStateOutput(this.ctx.utxo.value)) == this.ctx.hashOutputs)
}
}
- Visual Studio Code can also be used for Solidity with various extensions. However, its support is extremely limited compared to that of sCrypt, a TypeScript DSL, which is supported out of box without any extension. For example, VS Code debugger has first-class comprehensive support for sCrypt, but does not suppport Solidity.↩