Assets, Ethereum

How Do You Start Truffle Ethereum?

In order to start developing dapps on the Ethereum blockchain, you’ll need to first install and set up Truffle. Truffle is a development environment, testing framework and asset pipeline for Ethereum, which makes it easier to develop smart contracts and allows you to deploy them to the Ethereum blockchain.

Installing Truffle is simple. First, make sure you have Node.

js installed on your machine. Then, open up a terminal and run the following command:.

npm install -g truffle

This will install the Truffle command line interface globally on your machine. Once that’s done, you can verify that Truffle has been properly installed by running the command:

truffle version

You should see something like this:

Truffle v4.1.14 (core: 4.1.14) Solidity v0.4.24 (solc-js) Node v9.11.1 Web3.js v1.0.0-beta.55

Now that we have Truffle installed, we can create a new project directory and initialize it with Truffle:

NOTE: Warning: Before starting Truffle Ethereum, users should have a good understanding of Ethereum and its fundamentals. Additionally, users should be familiar with Solidity and the basics of programming in general. Furthermore, users should ensure that they have the correct environment set up with Node.js, npm and the correct version of Truffle installed. Failure to do so can lead to errors or unexpected results when using Truffle Ethereum.

mkdir my-project cd my-project truffle init

This will create a new directory called my-project with the following structure:
– contracts/: Where our Solidity smart contracts will live
– migrations/: Where our migration scripts are located
– test/: Where our automated tests are located
– truffle-config.js: Our project’s configuration file
– truffle.js: Another configuration file used by Truffle

Next, we need to configure our project to connect to an Ethereum network. By default, Truffle is configured to connect to a local development blockchain called Ganache . This blockchain is created automatically when you run the following command:

ganache-cli

If you don’t already have ganache-cli installed, you can install it with npm by running the following command:

npm install -g ganache-cli

Once ganache-cli is up and running, you should see something like this:

Ganache CLI v6 . 2 . 5 (ganache – core : 2 . 3 . 3 ) Available Accounts ================== ( 0 ) 0 x627306090abaB3A6e1400e9345bC60c78a8BEf57 ( 100 ETH ) ( 1 ) 0xf17f52151EbEF6C7334FAD080c5704D77216b732 ( 100 ETH ) ( 2 ) 0 xC5fdf4076b8F3A5357c5E395ab970B5B54098Fef ( 100 ETH ) . Private Keys ================== ( 0 ) 95 c098d4254df728ae766ab58193892ec0bcbd20e1cb08f9405f8ed6da46af2d77 ( 1 ) eebdc05d409989d65adfb44a2ea7082caa3261efb86b2e0364ba3ad93cd01855 ( 2 ) bbb26db4c4d3091370b74ca21ea588faaebe07a29ae429fa37aa92e2eea09471 . HDWalletProvider ================== Connecting gas : 6721975 gasPrice : 20000000000 balance : 990000000000000000 < Connection options = { " network_id " : " * " , // Any network id " from " : " 0x627306090abaB3A6e1400e9345bC60c78a8BEf57 " // default address to use for any transaction Truffle sends through HTTP } > accounts [ ‘ 0x627306090abaB3A6e1400e9345bC60c78a8BEf57 ‘ ] balance : 990000000000000000 gasPrice : 20000000000 gas : 6721975 Nonce : 2 < Connection options = { " network_id " : 4 , // Any network id " from " : " 0xf17f52151EbEF6C7334FAD080c5704D77216b732 " // default address to use for any transaction Truffle sends through HTTP } > accounts [ ‘ 0xf17f52151EbEF6C7334FAD080c5704D77216b732 ‘ ] balance : 1000000000000000000 gasPrice : 20000000000 gas : 6721975 Nonce : 3 < Connection options = { " network_id " : 42 , // Any network id " from " : " 0xC5fdf4076b8F3A5357c5E395ab970B5B54098Fef " // default address to use for any transaction Truffle sends through HTTP } > accounts [ ‘ 0xC5fdf4076b8F3A5357c5E395ab970B5B54098Fef ‘ ] balance : 1000000000000000000 gasPrice : 20000000000 gas : 6721975 Nonce : 4 Network up ! Deploying contracts . Migrations completed successfully . Network up ! Running migrations . Running migration: 1 _initial_migration . js Replacing Migrations. Replacing Migrations. Migration # 1 completed successfully . Running migration: 2 _deploy_contracts . js Replacing MetaCoin. Replacing MetaCoin. MetaCoin deployed at 0 x8cf487EEF1ae16588090BDA360163D53353CF38D Migration # 2 completed successfully . Network up ! Your contracts have been deployed in development mode . Note that it ‘ s not safe to test your contracts with real ETH on mainnet or testnets – the addresses below are created just for that purpose , and the private keys are exposed in order for MetaMask and similar wallets work properly with them .

Contract Address ——————– MetaCoin 0 x8cf487EEF1ae16588090BDA360163D53353CF38D Migrations 0xd04116Cd2620776C01FFBF58252781554d562518 To test your contracts , run `truffle test` or use one of these frontends or IDEs listed below http://trufflerunnerformacosx10 12 +byblockappscom http://remixidebyethereumorg https://githubcom/BlockchainLabsnz/ide https://githubcom/trufflesuite/trufflesuitehttps://githubcom/ModularProject/modular Before moving on , remember to kill the node instance that `ganache – cli` created by pressing `ctrl + c` in its terminal window.

Previous ArticleNext Article