Skip to content

Instantly share code, notes, and snippets.

@rubensayshi
Last active July 7, 2016 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rubensayshi/0c8506f6222e9e381b3b36025afbd4b5 to your computer and use it in GitHub Desktop.
Save rubensayshi/0c8506f6222e9e381b3b36025afbd4b5 to your computer and use it in GitHub Desktop.

** MANY THINGS IN THIS DOCUMENT ARE HEAVILY SIMPLIFIED, THE PURPOSE IS PROVIDING SOMEONE WITHOUT ANY PRIOR KNOWLEDGE TO BE ABLE TO HELP WITH THE PROBLEM AT HAND! **

What is Bitcoin

To much to explain; but key points:

  • Cryptocurreny (Ownership by privatekey crypto)
  • BTC is divisible up to 8 decimal places. (1.00000000)
  • Decentralized by miners racing to create a block (at random) by expending CPU cycles to find the next block
  • on average 1 block every 10min
  • it has a controlled supply where every 4 years the amount of BTC rewarded for finding a block is halved,
    eventually reaching the 0.00000000 BTC / block reward in ~2140 and capping the amount of BTC at 21000000 BTC (see: https://en.bitcoin.it/wiki/Controlled_supply)

What is Counterparty

Counterparty is an embedded consensus protocol that runs on the Bitcoin Blockchain to provide asset registration and transactions.

Examples

You can issue 1000 GOLDTOKEN, claim that it resembles ownership of 1/1000th of a gold bar in your vault and people can trade the token.

Or (real world case) you can build a digital card game where each card is represented with a Counterparty token, eg; CARD_RED_DRAGON, CARD_WIZZARD, CARD_SMITHY.
So when a user buys a card he get's the ownership of these tokens and can trade / sell the tokens on the free market.
It's possible to set a maximum on how many tokens can be issued of one type, making a card rare.

What is XCP

Apart from the assets that users can create and transact with Counterparty has a 'native currency' called XCP.
This is the digital token that is previously used by users to pay for creating an asset, this mechanic prevents spam (name squatters).

Apart from that XCP is often also use as an intermediate step when trading / selling / buying assets, because there's no market to trade 1 CARD_RED_DRAGON for 3 CARD_WIZZARDs, so instead the CARD_RED_DRAGON is sold for 100 XCP and you can buy 3 CARD_WIZZARDs for that.

The currency is traded on a few exchanges, against BTC, with the current price being 0.00400100 BTC for 1 XCP (~$2.2).

The currency has a limited supply, because the only way to get XCP was during the first months of Counterparty launch in 2014.
You could get XCP by destroying BTC until the end of the burn phase.
Total Burned: 2125 BTC Total Earned: 2,649,791 XCP

In the meantime 59,216 assets were created which (at 0.5 XCP / asset) puts us at a total supply of: 2,620,183 XCP.

XCP is divisible up to 8 decimal places. (1.00000000)

What is a Smart Contract

A 'Smart Contract' is a (small) piece of code that is used to define 'rules' to a 'contract'.
The contracts we're talking about for the EVM are 'turing complete', basicly meaning they can do 'anything' any other programming language could do.

Examples

You could create a smart contract for crowdfunds;
The contract would allow a user to create a a campaign by setting a recipient, goal and deadline.
Then other users can send XCP to the campaign of their choosing, when the goal is reached before the deadline the XCP gather is send to the recipient, when the deadline is reached before the goal the XCP is returned to the contributors.

What is the EVM

The EVM is the 'Virtual Machine' that Ethereum developed.
It's the piece of the software that can run the turing complete smart contract.

The EVM on Counterparty

When the EVM runs on Counterparty everytime a user creates a smart contract or execute a smart contract it a bitcoin transaction is created which contains the information neccesary to do so.
Every Counterparty server node then executes the information in that bitcoin transaction and because all nodes are looking at the same (secure bitcoin) blockchain they all execute those transactions in the same order.
This way each node will have the same results at all times.

Contract Execution Cost

Because the contracts you create and execute are evaluated by every node there is a cost involved for each node operator, every contract (depending on it's complexity) costs a certain amount of memory and CPU power to evaluated / validate.
To prevent someone creating a very complex contract (or even an infinite contract that never stops running) a mechanism called 'gas' is introduced; when the contract is being evaluated every operation it does has a cost (eg; saving something big in memory is more expensive than saving something small in memory or sending XCP to 1000 people is more expensive than sending XCP to 1 person).
To create or execute a contract you provide a small amount of XCP upfront to cover the cost, while running this is slowly 'used' and once done the remainder is returned to you (technically you can estimate the exact amount required and send that).
The XCP that is 'used' is destroyed, because Counterparty doesn't have a way to reward node operators (because Counterparty transactions are embedded in the the bitcoin blockchain transactions and included in the blockchain by bitcoin miners), the implicit reward is the destroying deflating the XCP supply and increasing the value of XCP.

Gas per Block Limit

There should be a limit on how much gas can be expended in 1 block, to prevent an attacker creating a block that takes too long to evaluate.
This limit will be determined based on benchmarks.

Gas Cost Formula

The amount of gas required should slowly decrease to ensure that the burning of XCP doesn't result in all the XCP in circulation is eventually burned.
In addition to that it could be desirable to give a discount when the usage of smart contracts in the past X blocks, to reward early adoptors.

This is the actual problem we're at right now; what would be the formula of the gas cost.

A simple solution would be that the gas cost is 0.00001% of the total supply, with XCP being divisble by up to 8 decimals this would prevent reaching 0.00000000 for a long time.

But the main issue here is that we need some solid arguments on the actual numbers here and how to calculate how long it would take to reach 0 in this manner and plot these kinda things on a graph etc.
Preferably this should be as easy to explain and estimate as the bitcoin controlled supply.

On a side note; the cost of creating a new token (which is 0.5 XCP atm) should also scale along with that formula.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment