Let’s compare the smart contract capabilities in BTC and ETH by looking at their respective languages.

Abhishek Sharma
Crypticocean
Published in
3 min readMar 12, 2024

What is the BRC20 standard? How it is different from the ERC20 standard, what are the similarities?

I’ll start by providing examples of a basic ERC-20 smart contract for the Ethereum Virtual Machine (EVM) written in Solidity, and a basic BRC-20 smart contract for the Stacks platform written in Clarity. Then, I’ll compare both contracts in terms of their differences and similarities.

ERC-20 Smart Contract (Ethereum, Solidity)

Here is a simplified version of an ERC-20 token contract written in Solidity for the Ethereum platform:

solidity code
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract ERC20Token {
string public name;
string public symbol;
uint8 public decimals = 18;
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
constructor(string memory _name, string memory _symbol, uint256 _totalSupply) {
name = _name;
symbol = _symbol;
totalSupply = _totalSupply * 10 ** uint256(decimals);
balanceOf[msg.sender] = totalSupply;
}
function transfer(address _to, uint256 _value) public returns (bool success) {
require(balanceOf[msg.sender] >= _value);
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
emit Transfer(msg.sender, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool success) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_value <= balanceOf[_from]);
require(_value <= allowance[_from][msg.sender]);
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
allowance[_from][msg.sender] -= _value;
emit Transfer(_from, _to, _value);
return true;
}
}

BRC-20 Smart Contract (Stacks, Clarity)

Below is a basic BRC-20 token contract template in Clarity for the Stacks platform. Note that Clarity has a different syntax and operates under a different set of principles (e.g., it’s interpreted directly on the blockchain for transparency and security):

clarity
(define-fungible-token brc20-token)
(define-public (transfer (amount uint) (sender principal) (recipient principal))
(begin
(ft-transfer? brc20-token amount sender recipient)
(ok true)
)
)
(define-public (mint (amount uint))
(ft-mint? brc20-token amount tx-sender)
)
(define-public (burn (amount uint))
(ft-burn? brc20-token amount tx-sender)
)

Comparison Table

Differences and Similarities:

  • Language & Platform: The most apparent difference is the programming language and blockchain platform. Solidity is used for Ethereum, and Clarity is for Stacks.
  • Execution Environment: Solidity contracts are compiled to bytecode and executed on the EVM, whereas Clarity contracts are interpreted directly on the Stacks blockchain, which enhances transparency and security.
  • Token Standards: Both contracts implement their platform’s standard for fungible tokens (ERC-20 for Ethereum and BRC-20 for Stacks), but they offer different sets of basic functionalities tailored to their respective ecosystems.
  • Decimals & Precision: ERC-20 contracts typically use 18 decimal places for token amounts, while in Clarity, the precision is defined by the contract developer.

For smart contract development and Audit BRC 20 standard please contact

--

--