Skip to content

Smart Contract

Izek edited this page Apr 5, 2022 · 5 revisions

A computer program or a transaction protocol which is intended to automatically execute, control or document legally relevant events and actions according to the terms of a contract or an agreement.


A smart contract is a self-executing contract with the terms of the agreement between buyer and seller being directly written into lines of code. The code and the agreements contained therein exist across a distributed, decentralized blockchain network. The code controls the execution, and transactions are trackable and irreversible.

Smart contracts permit trusted transactions and agreements to be carried out among disparate, anonymous parties without the need for a central authority, legal system, or external enforcement mechanism.

While blockchain technology has come to be thought of primarily as the foundation for bitcoin​, it has evolved far beyond underpinning the virtual currency.

How Smart Contracts Work

Smart contracts were first proposed in 1994 by Nick Szabo, an American computer scientist who invented a virtual currency called "Bit Gold" in 1998, fully 10 years before the invention of bitcoin. In fact, Szabo is often rumored to be the real Satoshi Nakamoto, the anonymous inventor of bitcoin, which he has denied.

Szabo defined smart contracts as computerized transaction protocols that execute terms of a contract. He wanted to extend the functionality of electronic transaction methods, such as POS (point of sale), to the digital realm.

In his paper, Szabo also proposed the execution of a contract for synthetic assets, such as derivatives and bonds. Szabo wrote: "These new securities are formed by combining securities (such as bonds) and derivatives (options and futures) in a wide variety of ways. Very complex term structures for payments can now be built into standardized contracts and traded with low transaction costs, due to computerized analysis of these complex term structures."

Similar to a transfer of value on a blockchain, deployment of a smart contract on a blockchain occurs by sending a transaction from a wallet for the blockchain. The transaction includes the compiled code for the smart contract as well as a special receiver address. That transaction must then be included in a block that is added to the blockchain, at which point the smart contract's code will execute to establish the initial state of the smart contract. Byzantine fault-tolerant algorithms secure the smart contract in a decentralized way from attempts to tamper with it. Once a smart contract is deployed, it cannot be updated. Smart contracts on a blockchain can store arbitrary state and execute arbitrary computations. End clients interact with a smart contract through transactions. Such transactions with a smart contract can invoke other smart contracts. These transactions might result in changing the state and sending coins from one smart contract to another or from one account to another.

Sputnik DAO Contracts

A simple version of a DAO to give out tips, bounties and grants. Allows anyone to send a proposal to reward other people with funds and get a council to vote for it.

The major difference with Moloch DAO design is that this contract would receive its function via donation and council has equal rights.

Spec for v1:

  • Contract contains all the $NEAR in itself. It's initialized with it or receives later in form of donation.
  • There are council members: list of accounts that can vote for various activity. All council members have equal weight.
  • Next methods are available that can be called by anyone who attaches bond $NEAR (to prevent spam):
    • Add new council member
    • Remove council member
    • Given funds to receiver for description (up to 280 characters) and proposed amount
    • Finalize proposal When proposal has passed the require time, anyone can call to finalize it. Rules for passing proposal see below.
    • X of votes to approve proposal depends on the "policy": Policy allows to set number of votes required for different amount of funds spent.
  • Only council members (or self) can call:
    • vote for a given proposal.
  • Finalize proposal can be called - If this vote achieves >50% of council members saying "YES" - it executes action on success.
  • Upgradability with super majority vote of the council

Voting policy is a list of amounts and number or percentage of votes required. Where the last number in the list is used for all the non payouts (let's call it MAX_VOTE).

Astro DAO and Sputnik DAO Smart contracts:

Astro (Sputnik-v2): https://github.com/near-daos/sputnik-dao-contract/tree/main/sputnikdao2

​ Sputnik DAO: Sputnik DAO 2 Repo

Astro App

AstroDAO App

Tech Stack

Architecture

Entities

DAOs

Users

Groups

Proposals

Bounties

Treasury

Storage

Processes

Transaction

Voting

Completing a Bounty

Lockup Contracts Delegation

Search

Tips and Tricks

Use Cases

Ecosystem

NEAR

Smart Contract

NEAR CLI

Gas

Bond

Clone this wiki locally