MOVE THE FACEBOOK LANGUAGE

Move Note to readers: On December 1, 2020, the Libra Association was renamed to Diem Association. This report was published before the Association released White Paper v2.0 in April 2020, which included a number of key updates to the Libra payment system. Outdated links have been removed, but otherwise, this report has not been modified to incorporate the updates and should be read in that context. Features of the project as implemented may differ based on regulatory approvals or other considerations, and may evolve over time. https://developers.diem.com/main/docs/move-paper We present Move, a safe and flexible programming language for the Diem Blockchain. Move is an executable bytecode language used to implement custom transactions and smart contracts. The key feature of Move is the ability to define custom resource types with semantics inspired by linear logic: a resource can never be copied or implicitly discarded, only moved between program storage locations. These safety guarantees are enforced statically by Move’s type system. Despite these special protections, resources are ordinary program values — they can be stored in data structures, passed as arguments to procedures, and so on. First-class resources are a very general concept that programmers can use not only to implement safe digital assets but also to write correct business logic for wrapping assets and enforcing access control policies. The safety and expressivity of Move have enabled us to implement significant parts of the Diem protocol in Move, including Diem coin, transaction processing, and validator management. The Move Book Warning: Content on this page is outdated and requires rework. A newer version of Move IDE will be published soon. For now I recommend you to use move-cli. As with any compiled language, you need a proper set of tools to compile, run and debug your Move applications. Since this language is created for blockchains and used only within them, running scripts off-chain is a non-trivial task: every module will require an environment, account handling and compile-publishing system. To simplify development of Move modules I’ve created Move IDE extension for Visual Studio Code. This extension will help you cope with environment requirements. Use of this extension is highly recommended as it will handle the build/run environment for you, hence will let you focus on learning Move language instead of struggling with the CLI. This extension also includes Move syntax highlighting and executor to help debug your applications before going public. Install Move IDE To install it you’ll need: 1. VSCode (version 1.43.0 and above) – you can get it here; if you already have one – proceed to the next step; 2. Move IDE – once VSCode is installed, follow this link to install the newest version of IDE. Setup environment Move IDE proposes a single way of organizing your directory structure. Create a new directory for your project and open it in VSCode. Then setup this directory structure: modules/ – directory for our modules scripts/ – directory for transaction scripts out/ – this directory will hold compiled sources Also you’ll need to create a file called .mvconfig.json which will configure your working environment. This is a sample for libra: { “network”: “libra”, “sender”: “0x1” } Alternatively you can use dfinance as network: { “network”: “dfinance”, “sender”: “0x1” } dfinance uses bech32 ‘wallet1…’ addresses, libra uses 16-byte ‘0x…’ addresses. For local runs and experiments 0x1 address is enough – it’s simple and short. Though when working with real blockchains in testnet or production environment you’ll have to use the correct address of the network you’ve chosen. Your very first application with Move Move IDE allows you to run scripts in a testing environment. Let’s see how it works by implementing gimme_five() function and running it inside VSCode. Create module Create a new file called hello_world.move inside modules/ directory of your project. // modules/hello_world.move address 0x1 { module HelloWorld { public fun gimme_five(): u8 { 5 } } } If you decided to use your own address (not 0x1) – make sure you’ve changed 0x1 in this file and the one below Write script Then create a script, let’s call it me.move inside scripts/ directory: // scripts/run_hello.move script { use 0x1::HelloWorld; use 0x1::Debug; fun main() { let five = HelloWorld::gimme_five(); Debug::print(&five); } } Then, while keeping your script open follow these steps: 1. Toggle VSCode’s command palette by pressing ⌘+Shift+P (on Mac) or Ctrl+Shift+P (on Linux/Windows) 2. Type: >Move: Run Script and press enter or click when you see the right option. Voila! You should see the execution result – log message with ‘5’ printed in debug. If you don’t see this window, go through this part again. Your directory structure should look like this: modules/ hello_world.move scripts/ run_hello.move out/ .mvconfig.json You can have as many modules as you want in your modules directory; all of them will be accessible in your scripts under address which you’ve specified in .mvconfig.json