├── migrations ├── 1_initial_migration.js └── 2_deploy_contracts.js ├── contracts ├── VyperStorage.vy └── Migrations.sol ├── truffle-box.json ├── test └── vyperStorage.js ├── README.md ├── LICENSE └── truffle-config.js /migrations/1_initial_migration.js: -------------------------------------------------------------------------------- 1 | var Migrations = artifacts.require("./Migrations.sol"); 2 | 3 | module.exports = function(deployer) { 4 | deployer.deploy(Migrations); 5 | }; 6 | -------------------------------------------------------------------------------- /migrations/2_deploy_contracts.js: -------------------------------------------------------------------------------- 1 | var VyperStorage = artifacts.require("VyperStorage"); 2 | 3 | module.exports = function(deployer) { 4 | deployer.deploy(VyperStorage); 5 | }; 6 | -------------------------------------------------------------------------------- /contracts/VyperStorage.vy: -------------------------------------------------------------------------------- 1 | stored_data: uint256 2 | 3 | @external 4 | def set(new_value : uint256): 5 | self.stored_data = new_value 6 | 7 | @external 8 | @view 9 | def get() -> uint256: 10 | return self.stored_data 11 | -------------------------------------------------------------------------------- /truffle-box.json: -------------------------------------------------------------------------------- 1 | { 2 | "ignore": ["README.md", "LICENSE", ".gitignore", "box-img-lg.png", "box-img-sm.png"], 3 | "commands": { 4 | "Compile": "truffle compile", 5 | "Migrate": "truffle migrate", 6 | "Test contracts": "truffle test" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/vyperStorage.js: -------------------------------------------------------------------------------- 1 | const VyperStorage = artifacts.require("VyperStorage"); 2 | 3 | contract("VyperStorage", () => { 4 | it("...should store the value 89.", async () => { 5 | const storage = await VyperStorage.deployed(); 6 | 7 | // Set value of 89 8 | await storage.set(89); 9 | 10 | // Get stored value 11 | const storedData = await storage.get(); 12 | 13 | assert.equal(storedData, 89, "The value 89 was not stored."); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /contracts/Migrations.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.4.21 <0.6.0; 3 | 4 | contract Migrations { 5 | address public owner; 6 | uint public last_completed_migration; 7 | 8 | constructor() public { 9 | owner = msg.sender; 10 | } 11 | 12 | modifier restricted() { 13 | if (msg.sender == owner) _; 14 | } 15 | 16 | function setCompleted(uint completed) public restricted { 17 | last_completed_migration = completed; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Vyper Example Box 2 | ================= 3 | 4 | This box contains a simple `VyperStorage` contract to show the basics of using 5 | Vyper with Truffle. 6 | 7 | ## Installation 8 | 9 | 1. Install Truffle globally. Make sure you have v5.0.0 or higher. 10 | ``` 11 | npm install -g truffle 12 | ``` 13 | 14 | 2. Download the box. This also takes care of installing the necessary dependencies. 15 | ``` 16 | truffle unbox vyper-example 17 | ``` 18 | 19 | 3. Run the development console. 20 | ``` 21 | truffle develop 22 | ``` 23 | 24 | 4. Compile and migrate the smart contracts. Note inside the development console we don't preface commands with `truffle`. 25 | ``` 26 | compile 27 | migrate 28 | ``` 29 | 30 | 5. Run the tests. 31 | ``` 32 | // If inside the development console. 33 | test 34 | 35 | // If outside the development console.. 36 | truffle test 37 | ``` 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2018 Truffle 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /truffle-config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Use this file to configure your truffle project. It's seeded with some 3 | * common settings for different networks and features like migrations, 4 | * compilation and testing. Uncomment the ones you need or modify 5 | * them to suit your project as necessary. 6 | * 7 | * More information about configuration can be found at: 8 | * 9 | * truffleframework.com/docs/advanced/configuration 10 | * 11 | * To deploy via Infura you'll need a wallet provider (like truffle-hdwallet-provider) 12 | * to sign your transactions before they're sent to a remote public node. Infura API 13 | * keys are available for free at: infura.io/register 14 | * 15 | * You'll also need a mnemonic - the twelve word phrase the wallet uses to generate 16 | * public/private key pairs. If you're publishing your code to GitHub make sure you load this 17 | * phrase from a file you've .gitignored so it doesn't accidentally become public. 18 | * 19 | */ 20 | 21 | // const HDWallet = require('truffle-hdwallet-provider'); 22 | // const infuraKey = "fj4jll3k....."; 23 | // 24 | // const fs = require('fs'); 25 | // const mnemonic = fs.readFileSync(".secret").toString().trim(); 26 | 27 | module.exports = { 28 | } 29 | --------------------------------------------------------------------------------