Skip to main content

Overview

A smart contract is a computer protocol designed to disseminate, validate or enforce contracts in an informational manner. Smart contracts allow trusted transactions to be made without a third party, and these transactions are traceable and irreversible.

The purpose of smart contracts is to prevent tampering with transaction data, ensure the integrity of the transaction process, and ensure the irreversibility of the outcome by utilizing consensus mechanisms and tamper-proof ledger technology. Compared with traditional contracts, smart contracts implement the terms of the contract in the form of programming code and automatically execute the relevant actions when specific conditions are met, without human involvement. It creates a relationship of trust between different parties and avoids the increase in transaction costs caused by mistrust.

Characteristics

- Normative.
Smart contracts are based on computer code that can minimize linguistic ambiguity and are presented through a strict logical structure. The content and execution process is transparent to all nodes, who can observe, record and verify the contract status through the user interface.

- Irreversibility.
Once the conditions are met, the contract automatically executes the intended plan, and given the factual inputs, the smart contract will always output the correct result, which is visualized in the display view.

- Non-default.
The transaction information on the blockchain is open and transparent, and each node can trace the transaction process recorded on the blockchain, so the chance of default is extremely low.

- Anonymity.
According to the cryptographic principle of asymmetric encryption, zero-knowledge proof, ring signature, blind signature and other technologies, on the blockchain, although the transaction process is public, the transaction parties are anonymous.

Advantages

  1. Smart contract removes the intermediary, can rely entirely on technology to allow users to establish contracts between themselves.

  2. Transparent and fair. Smart contract will use the code to write the conditions clearly and record them on the blockchain. The whole process is executed by the programme and cannot be tampered with even by the developer who wrote the code.

  3. Flexible. So that users can freely establish contracts with each other, even with a stranger can be established through smart contracts. Overall, smart contracts are one of the core technologies of the blockchain. Not only does it play an executive role in the blockchain, but it is also an application development direction of the blockchain. It broadens the use of blockchain, and it is because of its existence that blockchain has a broader stage.

Development Process

Transformers uses Solidity, an object-oriented high-level programming language, to write smart contracts. The EVM used by Transformers supports most of the features of the Solidity standard, and has already supported contract standards such as ERC-20, ERC-721, ERC-3525, etc. Transformers contracts are cheaper to execute and faster to chain than Ether. Compared with Ethereum, Transformers contracts are cheaper to execute and faster to chain.

1.To use smart contract related functions, you need to be familiar with the Solidity language, the link about Solidity is as follows:

2.Smart contracts need to be compiled into EVM bytecode for deployment and execution. The compilation link of Solidity smart contract is as follows:

  1. Transformers differs from the Solidity standard by the following features due to its architectural model:
  • The basic unit of transfer of Transformers coins within the contract is 1e-8 Transformers.
  • Contracts do not support block variables
  • Transformers account addresses include multiple smart contract addresses.

Deploying the contract

Differences and similarities

Since Transformers is a DAG network structure and Ether is a single-chain structure, and its consensus mechanism is not exactly the same. Solidity's certain commands have been adjusted in the EVM virtual machine, the specific differences are as follows:

block.basefee:1
block.chainid:518
block.coinbase: packer
block.prevrandao: Random numbers generated by splicing and summing with utxo hash for exchanges.
block.gaslimit (uint): 9223372036854776028
block.number:Block height
block.timestamp: The blockTimestamp field in TxInfo is generally a block timestamp accurate to the second, but may be inaccurate by a few seconds.
gasleft(): Remaining gas fee
tx.gasprice: 1
tx.origin: Transaction initiator
blockhash:Returns 0 because block.number has different semantics.

Transformers Other Applications

The Transformer node provides many RPC interfaces for third-party developers regarding contracts. Here we focus on the process of third-party developers accessing TFSC to send transactions. For details, please refer to Contract related APIs