👋
Vision Network
  • Vision Basics
    • Vision Network
    • VS and VRC
    • The GitBook editor
    • Token Issuance
    • Minting Mechanism
  • Protocol
    • Account
    • Resource Model
    • Economic model
    • Multi-Signature
    • Transaction
    • Validator
      • First Validator & Reward Mechanism
      • To be Validated Candidate
      • Proposal and Committee
  • SMART CONTRACTS
    • Introduction
    • Deployment Cost
    • DevOps Flow
    • Key considerations
    • Security considerations
    • Features
      • Protobuf
      • Function Usage
      • Contract Address
      • Different Form Ethereum
  • VIRTUAL MACHINE
    • Introduction
    • Event
    • Entropy Costs Calculation
    • VM Exception Handling
    • Features between Ethereum
  • HTTP API
  • Signature and Broadcast Steps
  • Infragrid guide
  • Vtimes chrome integration
  • Introduction
  • Getting Started
  • Group 1
    • Introduction
    • GUI and Usage
  • VISION-WEB
    • Introduction
  • VISION WALLET
    • Vtimes Chrome Plugin
    • Visionscan
    • Metamask
  • DECENTRALIZED EXCHANGES
    • Operating principle
    • Trading pairs
    • Liquidity pool
  • Others
    • Term
Powered by GitBook
On this page
  • 1. address conversion
  • 2. address judgement
  • 3. variable assignment
  1. SMART CONTRACTS
  2. Features

Contract Address

Ethereum VM address is 20 bytes, but Vision's VM address is 21 bytes.

1. address conversion

Need to convert Vision's address while using in solidity (recommended):

/**
  * @dev convert uint256 (HexString add 0x at beginning) vision address to solidity address type
  * @param  visionAddress uint256 visionAddress, begin with 0x, followed by HexString
  * @return Solidity address type
  */
     
function convertFromVisionInt(uint256 visionAddress) public view returns(address){
      return address(visionAddress);
}

This is similar with the grammar of the conversion from other types converted to address type in Ethereum.

2. address judgement

Solidity has address constant judgement, if using 21 bytes address the compiler will throw out an error, so you should use 20 bytes address, like:

function compareAddress(address visionAddress) public view returns (uint256){
     // if (visionAddress == 0x46817ffa3d2f2028fcb9b8d2c619448cb3e3934c47) { // compile error
     if (visionAddress == 0x817ffa3d2f2028fcb9b8d2c619448cb3e3934c47) { // right
          return 1;
     } else {
          return 0;
     }
}

But if you are using wallet-cli, you can use 21 bytes address, like 0000000000000000000046817ffa3d2f2028fcb9b8d2c619448cb3e3934c47

3. variable assignment

Solidity has address constant assignment, if using 21 bytes address the compiler will throw out an error, so you should use 20 bytes address, like:

function assignAddress() public view {
     // address newAddress = 0x46817ffa3d2f2028fcb9b8d2c619448cb3e3934c47; // compile error
     address newAddress = 0x817ffa3d2f2028fcb9b8d2c619448cb3e3934c47;
     // do something
}
PreviousFunction UsageNextDifferent Form Ethereum

Last updated 3 years ago