Documentation
  • INTRODUCTION
  • USERS
    • White Paper
    • Main features of CyberWay
    • Bandwidth differences between EOS and CyberWay
    • Bandwidth implementation
    • How to Launch EOS dApps on CyberWay
    • Glossary
  • DEVELOPMENT ENVIRONMENT
    • Core Concepts
    • 1 Before You Begin
    • 2 Install the CDT
    • 3 Create Development Wallet
    • 4 Start keosd and nodeos
    • 5 Create Test Accounts
  • SOFTWARE MANUALS
    • Core
      • nodeos
      • cleos
      • keosd
      • cyberway.cdt
    • How To Guides
      • How To Ban An Unwanted Account
      • How To Calculate Reward For An Author
      • How To Calculate Reward For A Beneficiary
      • How To Calculate Reward For A Curator
      • How To Create A Wallet
      • How To Create An Account
      • How To Create A Proxy Account
      • How To Create Key Pair
      • How To Delegate Resources
      • How To Deploy A Node Using A Snapshot
      • How To Deploy A Smart Contract
      • How To Get Account Information
      • How To Get Block Information
      • How To Get Transaction Information
      • How To Import A Key
      • How To Link Permission
      • How To List All Key Pair
      • How To Stake Tokens
      • How To Stop A Node Using Docker
      • How To Submit A Proposal For HardFork
      • How To Transfer Tokens To A Worker
      • How To Undelegate Resources
      • How To Unlink Permission
      • How To Unstake Tokens
      • How To Vote
    • API Reference
      • Nodeos Chain API
      • Nodeos Producer API
      • Nodeos Net API
    • Cleos Command Reference
      • Convert
      • Create
      • Get
      • Multisig
      • Net
      • Push
      • Set
      • Sign
      • System
      • Transfer
      • Version
      • Wallet
    • Explorer Command Reference
      • How To Check Your Balance
      • How To Find Out Account ID
      • How To Convert Golos To Golos Power And Vice Versa
      • How To Stake Tokens CYBER
      • How To Transfer Funds From One Account To Another
      • How To Transfer Funds From Pending to Liquid
      • How To Bay Stake
      • How To Withdraw Stake
      • How To Vote For A Validator
      • How To Revoke Your Vote For A Validator
      • How To Bay Vesting Using Explorer
      • How To Vote For A Witness
      • How To Revoke Your Vote For A Witness
  • DEVPORTAL
    • System Contracts
      • BIOS
      • Domain names
      • Govern
      • Multi-Signature
      • Stake
      • Tokens
    • Application Contracts
      • Golos Contracts
        • Charge
        • Control
        • Emission
        • Publication
        • Referral program
        • Social
        • Vesting
        • Memo-keys
        • Determining Rewards for a Post
    • Guide to Creating and Deploying an Application on CyberWay
      • 1 Preliminary Work
      • 2 Creating a Simple Contract
      • 3 Creating Tokens
      • 4 Understanding ABI Files
      • 5 Data Persistence
      • 6 Secondary Indexes
      • 7 Adding Inline Actions
      • 8 Inline Action to External Contract
      • 9 Conclusion
    • The cyberway_wallet designed for the Bittrex market
    • The Event Model
  • VALIDATORS
    • Testnet Installation Guide
      • 1 General
      • 2 Configuring the Docker Image
      • 3 Create Container
      • 4 Connecting to a Node
      • 5 List of Commands Applicable to Any Kind of Container
    • Mainnet Connection Guide
      • Docker-Compose Start-up Instructions
      • APPENDIX A
      • APPENDIX B
    • Golos Blockchain Transit
    • How to join CyberWay for those who are interested in being validators ?
    • Stake Usage Guide
    • Regulations for CyberWay validators. Voting for Validators
Powered by GitBook
On this page
  • 3.1 Download contract source files
  • 3.2 Create an account for the contract
  • 3.3 Compile a contract
  • 3.4 Install Token contract
  • 3.5 Create a Token
  • 3.6 Releasing a Token
  • 3.7 Token transfer
  1. DEVPORTAL
  2. Guide to Creating and Deploying an Application on CyberWay

3 Creating Tokens

In CyberWay everybody can create his/her own type of tokens (In EOS this right applies to validators only). The tokens of the application should be deployed on a separate account from cyber.token. When creating tokens a developer can use a reference implementation of the cyber.token contract as a base by loading its contents into developer’s workspace.

3.1 Download contract source files

Enter the directory created for the contracts and load a copy of the remote repository with the contract source files into it.

cd CONTRACTS_DIR
git clone https://github.com/cyberway/cyberway.contracts --branch <branch name> --single-branch

The cyberway.contracts repository contains several contracts, but the cyber.token contract is required to create tokens.

cd cyberway.contracts/cyber.token

3.2 Create an account for the contract

Before you deploy a token-contract, you need to create an account of this contract by executing the following command line:

cleos create account olga olga.token <public key>

Command line parameters: olga — an account name for the contract being created; olga.token — a name of the token contract downloaded from the cyberway.contracts repository with the source files.

As an example a contract account has been created with the olga.token name.

3.3 Compile a contract

eosio-cpp -I include -o olga.token.wasm src/olga.token.cpp --abigen

The contract is compiled into a web assembler file wasm format. The presence of the --abigen option indicates that the abi/olga.token.abi file will also be generated.

3.4 Install Token contract

cleos set contract olga.token CONTRACTS_DIR/cyberway.contracts/olga.token --abi abi/olga.token.abi -p olga.token@active

Parameter: olga.token@active — a name that will be used to authorize the request.

The token contract will be considered successfully installed if the resulting output of the command being executed contains information of the form:

executed transaction:  ... 
#         eosio <= eosio::setcode               {"account":"olga.token","vmtype":0,"vmversion":0,"code":"<code>
#         eosio <= eosio::setabi                {"account":"olga.token","abi":"<code>
warning: transaction executed locally, but may not be confirmed by the network yet         ]

3.5 Create a Token

To create a new token use the action create. The argument is the type of the token symbol_name, which contains two values — the maximum value of the sentence and the symbol of the token. The call to this action has the form:

cleos push action olga.token create '{"issuer":"olga", "maximum_supply":"1000000000.0000 SYS"}' -p olga.token@active

The -p olga.token@active option authorizes the olga.token contract to perform this action.

Creating a token is considered successful if the following information appears on the monitor:

executed transaction: <info>
#   olga.token <= olga.token::create          {"issuer":"olga","maximum_supply":"1000000000.0000 SYS"}

As a result, a new token SYS will be created, which has an accuracy of four decimal digits. The maximum allowable number of tokens in circulation should be limited to the value of 1,000,000,000. To create this token, a permission of the contract olga.token is required. The name olga.token@active will be used when authorizing the request.

3.6 Releasing a Token

The author of a token can issue tokens to an already existing account, for example, to an account with the name «alice» by executing:

cleos push action olga.token issue '[ "alice", "100.0000 SYS", "memo" ]' -p olga@active

The following information should appear as a result of the command execution:

executed transaction:  ... 
#   olga.token <= olga.token::issue           {"to":"user","quantity":"100.0000 SYS","memo":"memo"}
>> issue
#   olga.token <= olga.token::transfer        {"from":"olga","to":"alice","quantity":"100.0000 SYS","memo":"memo"}
>> transfer
#         olga<= olga.token::transfer        {"from":"olga","to":"alice","quantity":"100.0000 SYS","memo":"memo"}
#          user <= olga.token::transfer        {"from":"olga","to":"alice","quantity":"100.0000 SYS","memo":"memo"}

The output contains one issue action and three transfer actions. At issue run time, three internal calls are additionally generated notifying the sender and receiver of tokens.

3.7 Token transfer

Some tokens can be transferred from the balance of one account to the balance of another account. For example, to transfer an amount of 25 tokens from the «alice» account balance to «bob» account balance you need to use the following command line:

cleos push action olga.token transfer '[ "alice", "bob", "25.0000 SYS", "m" ]' -p alice@active

To perform this action you need permission from the «alice» sender account — the -p alice@active option is available.

The transfer of tokens is considered as successfully completed if upon its completion the following information appears in the command window:

executed transaction:  ... 
#   olga.token <= olga.token::transfer        {"from":"alice","to":"bob","quantity":"25.0000 SYS","memo":"Here you go bob!"}
>> transfer
#          user <= olga.token::transfer        {"from":"alice","to":"bob","quantity":"25.0000 SYS","memo":"Here you go bob!"}
#        tester <= olga.token::transfer        {"from":"alice","to":"bob","quantity":"25.0000 SYS","memo":"Here you go bob!"}

To control the token transfer, you can use the get_currency_balance call to get the balance data of the sender and the receiver accounts by executing:

cleos get currency balance olga.token alice SYS
cleos get currency balance olga.token bob SYS
Previous2 Creating a Simple ContractNext4 Understanding ABI Files

Last updated 5 years ago