We are using window machine for this POC.
Make sure you have following software already installed in your machine.
1- Truffle
2- Ganache – as local test server
3- Infura credential to create project that can be used to connect to other live test env such as Robstan, Rinkesby etc.
In this poc we are going to use Ehereum block chain technologies with Solidity language for writing our smart contract.
We will also use Web wallet Metamask and Infura layer to connect our application/smart contract with live test environment.
So basically we will try to aceive following below given things sequentially.
1- Create a truffle project that will give us the framework for easy coding/maitainability and configurability for writing smart contract in solidity for ethereum.
2- Sender address : – This address will send ether crypto money to receiver
3- Receiver Address :- This address will receive ether crypto from senter
4- To connect our smart contract i.e. truffle
sender –> eth –> metamask –> receiver –> infura –> Robstan network
Lets start …
Step 1:- Create a simple truffle project
First check you have truffle available on your machine if not then please first install it.
Now to have a test server start your ganache.
Now lets create a folder and execute below truffle command to setup solidity block chain frame work
C:\Ethereum_workspace\siddhuethreuminfuraproject>truffle init
Starting init...
================
> Copying project files to C:\Ethereum_workspace\siddhuethreuminfuraproject
Init successful, sweet!
Try our scaffold commands to get started:
$ truffle create contract YourContractName # scaffold a contract
$ truffle create test YourTestName # scaffold a test
http://trufflesuite.com/docs
C:\Ethereum_workspace\siddhuethreuminfuraproject>
Now lets open our newly created project in VS Code IDE.
Now lets write our first simple smart contract that will send money (ether) from sender address to receiver address.
First lets discuss about the datatype and datafunction that will be needed by us
1- uint public amount = 0;
2- getSenderAmount(address _sender) – sender amount at given moment of time.
3- getReceiverAmount(address _receiver) – receiver amount at given moment of time.
4- sendAmount(address _receiver, uint _amount) that will take two parameter receiver address and amount do the operation of sending money.
Now as usual lets check it with remix so that we are sure that our smart contract is working.
SendMoney.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;
//Main class that will be used to perform operation on our block.
contract SendMoney
{
uint public amount = 0;
//address public receiver = 0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2;
function sendAmount(address _receiver, uint _amount) public payable
{
payable(_receiver).transfer(_amount * (1 ether));
}
function getSenderAmount(address _sender) public view returns(uint)
{
return (_sender).balance;
}
function getReceiverAmount(address _receiver) public view returns(uint)
{
return (_receiver).balance;
}
// function sendAmount() public payable {
// payable(receiver).transfer(1);
// }
}
Now as shown below we are able to transfer 1 ether from sender to receiver.
Now lets try to execute the same using ganache ui. Lets configure our remix
Note:- I am using now Remix app rather than web url.
After deployment of contract and sending the ether to receiver
Now as we confirm that our smart contract is working fine.
Let try to test it in our truffle environment using truffle console and javascript.
To test in truffle console execute below command sequenctially.
Step 1- make change in the truffle-config.js as given below as we are running our Ganache Test sever at localhost:7545
networks: {
development: {
host: "127.0.0.1", // Localhost (default: none)
port: 7545, // Standard Ethereum port (default: none)
network_id: "*", // Any network (default: none)
}
Step 2:- create a finel 2_SendMoney_migration.js inside migration folder with below code.
const Migrations = artifacts.require("SendMoney");
module.exports = function (deployer) {
deployer.deploy(SendMoney);
};
Step 3:- Now execute truffle compile command
C:\Ethereum_workspace\siddhuethreuminfuraproject>truffle compile
Compiling your contracts...
===========================
> Compiling .\contracts\Migrations.sol
> Compiling .\contracts\SendMoney.sol
> Artifacts written to C:\Ethereum_workspace\siddhuethreuminfuraproject\build\contracts
> Compiled successfully using:
- solc: 0.8.15+commit.e14f2714.Emscripten.clang
C:\Ethereum_workspace\siddhuethreuminfuraproject>
Step 4:- Now execute truffle deploy –development or truffle migrate –development command to deploy or migrate our smart contract on the Ganache Test server. You will see that there will be change in the Ether value of Sender address as we are deploying our smart contract on that address i.e it will be less with few amounts.
C:\Ethereum_workspace\siddhuethreuminfuraproject>truffle migrate --development
Compiling your contracts...
===========================
> Compiling .\contracts\Migrations.sol
> Compiling .\contracts\SendMoney.sol
> Artifacts written to C:\Ethereum_workspace\siddhuethreuminfuraproject\build\contracts
> Compiled successfully using:
- solc: 0.8.15+commit.e14f2714.Emscripten.clang
Starting migrations...
======================
> Network name: 'development'
> Network id: 5777
> Block gas limit: 6721975 (0x6691b7)
1_initial_migration.js
======================
Deploying 'Migrations'
----------------------
> transaction hash: 0xf3184d9892418f99665e1292417a4e9bc6734cd2b390c2315bdd4f1ef762ade3
> Blocks: 0 Seconds: 0
> contract address: 0x51eeEFeBa854e0d3a6c10Ca1803cbb00424d6AeF
> block number: 3
> block timestamp: 1661411956
> account: 0x3478b442E34F8C45D76AFAC74D3B1A8446Dbdb43
> balance: 98.98936988
> gas used: 248854 (0x3cc16)
> gas price: 20 gwei
> value sent: 0 ETH
> total cost: 0.00497708 ETH
> Saving migration to chain.
> Saving artifacts
2_SendMoney_migration.js
========================
Deploying 'SendMoney'
---------------------
> transaction hash: 0xee1efaacfe2415ef10ca539292e92175b921a3b50fa9ab9b83df5d37d4f9bf45
> Blocks: 0 Seconds: 0
> contract address: 0xE231FCdB8564ED79c5eE4FA23615aafD81504569
> block number: 5
> block timestamp: 1661411957
> account: 0x3478b442E34F8C45D76AFAC74D3B1A8446Dbdb43
> balance: 98.98357654
> gas used: 247154 (0x3c572)
> gas price: 20 gwei
> value sent: 0 ETH
> total cost: 0.00494308 ETH
> Saving migration to chain.
> Saving artifacts
-------------------------------------
> Total cost: 0.00494308 ETH
Summary
=======
> Total deployments: 2
> Final cost: 0.00992016 ETH
C:\Ethereum_workspace\siddhuethreuminfuraproject>
Note:- Due to some reason i had restarted mine Ganache app result into all new address on the screen.
Now as shown after deploying the contract we can see the first address ether is less than 100 which is default for all the address when starte. This indicate that our contact is deployed properly.
Now let test our deployed contract using truffle console.
Step 4:- excute this command truffle console
C:\Ethereum_workspace\siddhuethreuminfuraproject>truffle console
truffle(development)>
C:\truffle-project>truffle console
truffle(development)> let instance = await SendMoney.deployed();
undefined
truffle(development)> instance.getSenderAmount('0xe1A7fd227081d756Ec3FDA8aE1E5385b26168FEF');
truffle(development)> instance.getReceiverAmount('0xb4484f547FaEf63F5E2bb673796ABbfF38ED915B');
We had also written one more funtion sendCoin our complete sol file is
SendMoney.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;
//Main class that will be used to perform operation on our block.
contract SendMoney
{
//uint public amount = 0;
//address public receiver = 0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2;
//mapping (address => uint) balances;
event Transfer(address indexed _from, address indexed _to, uint256 _value);
constructor() {
//balances[tx.origin] = 100;
}
function sendCoin(address sender, address receiver, uint amount) public payable returns(bool sufficient) {
payable(receiver).transfer(amount * (1 ether));
emit Transfer(sender, receiver, amount);
return true;
}
function sendAmount(address _receiver, uint _amount) public payable
{
payable(_receiver).transfer(_amount * (1 ether));
}
function getSenderAmount(address _sender) public view returns(uint)
{
return (_sender).balance;
}
function getReceiverAmount(address _receiver) public view returns(uint)
{
return (_receiver).balance;
}
// function sendAmount() public payable {
// payable(receiver).transfer(1);
// }
}
Finally we will test our smart contract writting new smartcontract in Test folder as test case. create sendmoney.js and write below code in it
1- sendmoney.js:-
const SendMoney = artifacts.require('SendMoney');
// contract('SendMoney', function(accounts) {
// it('calling a SendMoney', async function () {
// const contract = await SendMoney.deployed();
// await contract.sendAmount(accounts[1], 1);
// });
// });
contract("SendMoney", (accounts) => {
it("should send coin correctly", async () => {
const SendMoneyInstance = await SendMoney.deployed();
// Setup 2 accounts.
const accountOne = accounts[0];
const accountTwo = accounts[1];
// Get initial balances of first and second account.
const accountOneStartingBalance = (
await SendMoneyInstance.getSenderAmount(accountOne));
const accountTwoStartingBalance = (
await SendMoneyInstance.getReceiverAmount(accountTwo));
console.log('accountSenderStartingBalance-----------'+accountOneStartingBalance) ;
console.log('accountReceiverStartingBalance -----------'+accountTwoStartingBalance) ;
// Make transaction from first account to second.
const amount = 1;
await SendMoneyInstance.sendCoin(accountOne, accountTwo, amount, { value: web3.utils.toWei('1000000000000000000', 'wei'), from: accountOne });
// Get balances of first and second account after the transactions.
const accountOneEndingBalance = (
await SendMoneyInstance.getSenderAmount(accountOne));
const accountTwoEndingBalance = (
await SendMoneyInstance.getReceiverAmount(accountTwo));
console.log('accountSenderEndingBalance-----------'+accountOneEndingBalance) ;
console.log('amount -----------'+amount) ;
console.log('accountSenderEndingBalance - amount -----------'+(accountOneStartingBalance - amount));
assert.equal(
accountOneEndingBalance,
accountOneStartingBalance - amount,
"Amount wasn't correctly taken from the sender"
);
console.log('accountReceiverEndingBalance -----------'+accountTwoEndingBalance) ;
console.log('amount -----------'+amount) ;
console.log('accountReceiverStartingBalance - amount -----------'+(accountTwoStartingBalance - amount));
assert.equal(
accountTwoEndingBalance,
accountTwoStartingBalance + amount,
"Amount wasn't correctly sent to the receiver"
);
});
});
and execute below command it will test our smart contract.
lets take the screen shot of our user ether account before executing the test case
C:\Ethereum_workspace\siddhuethreuminfuraproject>truffle migrate --deployment --reset
Compiling your contracts...
===========================
> Compiling .\contracts\Migrations.sol
> Compiling .\contracts\SendMoney.sol
> Artifacts written to C:\Ethereum_workspace\siddhuethreuminfuraproject\build\contracts
> Compiled successfully using:
- solc: 0.8.15+commit.e14f2714.Emscripten.clang
Starting migrations...
======================
> Network name: 'development'
> Network id: 5777
> Block gas limit: 6721975 (0x6691b7)
1_initial_migration.js
======================
Replacing 'Migrations'
----------------------
> transaction hash: 0xb80add2f09e7c1f82f41b3cbff81af72942bbcf447bbbedeee7fa754cb30c287
> Blocks: 0 Seconds: 0
> contract address: 0xFeF8a92B775707B3e8c4cf2705bAA7EeB184008f
> block number: 115
> block timestamp: 1661431752
> account: 0xe1A7fd227081d756Ec3FDA8aE1E5385b26168FEF
> balance: 83.65342136
> gas used: 248854 (0x3cc16)
> gas price: 20 gwei
> value sent: 0 ETH
> total cost: 0.00497708 ETH
> Saving migration to chain.
> Saving artifacts
-------------------------------------
> Total cost: 0.00497708 ETH
2_SendMoney_migration.js
========================
Replacing 'SendMoney'
---------------------
> transaction hash: 0x423ebf826085c30ca1b2a5df11c1113f7e524aa82eb9aefce168849addac9245
> Blocks: 0 Seconds: 0
> contract address: 0x3444EF47b0Ac6243E4B82927533112788257BcD0
> block number: 117
> block timestamp: 1661431753
> account: 0xe1A7fd227081d756Ec3FDA8aE1E5385b26168FEF
> balance: 83.64600954
> gas used: 328078 (0x5018e)
> gas price: 20 gwei
> value sent: 0 ETH
> total cost: 0.00656156 ETH
> Saving migration to chain.
> Saving artifacts
-------------------------------------
> Total cost: 0.00656156 ETH
Summary
=======
> Total deployments: 2
> Final cost: 0.01153864 ETH
C:\Ethereum_workspace\siddhuethreuminfuraproject>truffle test
Using network 'development'.
Compiling your contracts...
===========================
> Compiling .\contracts\Migrations.sol
> Compiling .\contracts\SendMoney.sol
> Artifacts written to C:\Users\SIDDHA~1\AppData\Local\Temp\test--1236-AvwPLi40gbuk
> Compiled successfully using:
- solc: 0.8.15+commit.e14f2714.Emscripten.clang
Contract: SendMoney
accountSenderStartingBalance-----------180143901462299700000000000
accountReceiverStartingBalance -----------116000000000000000000
accountSenderEndingBalance-----------180143902462952340000000000
amount -----------1
accountSenderEndingBalance - amount -----------1.801439014622997e+26
1) should send coin correctly
Events emitted during test:
---------------------------
SendMoney.Transfer(
_from: <indexed> 0xe1A7fd227081d756Ec3FDA8aE1E5385b26168FEF (type: address),
_to: <indexed> 0xb4484f547FaEf63F5E2bb673796ABbfF38ED915B (type: address),
_value: 1 (type: uint256)
)
---------------------------
1 passing (718ms)
0 failing
we can cleary see that 1 ether is added to the receiver and less from sender that prove that our contract is working fine.
Till now everthing we werer doing was on the local host i.e. ganache and truffle all were local host test server. Now lets take integrate our smart contract with live test environment i.e. robstan.
Generally developer use GETH client to do the same. But it is my personal view good option is to use infura site. you need to first login to the system.
Signup first as i am already having the credential is am going to login directly.
First create a simple project as shown below.
Now as you can see it give you the simple string to connect any of the test environment.
chose the right test env we are going to use and copy that string we are fine to go with. we are chossing ropstan test env.
https://ropsten.infura.io/v3/be6523b046804030a748c667dee41dbc
API key
be6523b046804030a748c667dee41dbc
first install @truffle/hdwallet-provider using belwo command.
C:\Ethereum_workspace\siddhuethreuminfuraproject>npm install @truffle/hdwallet-provider
Now the only things we need to change is truffle-config file to inform our smartcontract to connect which env
add this line in it
const HDWalletPRovider = require("@truffle/hdwallet-provider");
var mnemonic = "Add your mnemonic of wallet";
ropsten: {
provider: function() {
return new HDWalletProvider(mnemonic, "https://ropsten.infura.io/v3/be6523b046804030a748c667dee41dbc");
},
network_id: 3,
gas: 4500000,
gasPrice: 10000000000,
}
so now our truffle-config.js will have these two entries
const HDWalletPRovider = require("@truffle/hdwallet-provider");
var mnemonic = "Add your mnemonic of wallet";
development: {
host: "127.0.0.1", // Localhost (default: none)
port: 7545, // Standard Ethereum port (default: none)
network_id: "*", // Any network (default: none)
},
ropsten: {
provider: function() {
return new HDWalletProvider(mnemonic, "https://ropsten.infura.io/v3/be6523b046804030a748c667dee41dbc");
},
network_id: 3,
gas: 4500000,
gasPrice: 10000000000,
},
now as we know if we want to add our contract to test environment the we must have ether in that account lets do the same now. Here we will use the metamask wallet to check if the amount is added in to the wallets.
Now to do that we can use the ropsten faucet account or you can also use the metamast to do the same. Follow the belwo step to add the ether to your account.
or you can go with this option
now lets move our contract to ropstan test environment using belwo command.
first compile all the files using belwo command.
C:\Ethereum_workspace\siddhuethreuminfuraproject>truffle compile --all
Compiling your contracts...
===========================
> Compiling .\contracts\Migrations.sol
> Compiling .\contracts\SendMoney.sol
> Artifacts written to C:\Ethereum_workspace\siddhuethreuminfuraproject\build\contracts
> Compiled successfully using:
- solc: 0.8.15+commit.e14f2714.Emscripten.clang
C:\Ethereum_workspace\siddhuethreuminfuraproject>
also try to compile for specific network
C:\Ethereum_workspace\siddhuethreuminfuraproject>truffle compile --network development
Compiling your contracts...
===========================
> Compiling .\contracts\Migrations.sol
> Compiling .\contracts\SendMoney.sol
> Artifacts written to C:\Ethereum_workspace\siddhuethreuminfuraproject\build\contracts
> Compiled successfully using:
- solc: 0.8.15+commit.e14f2714.Emscripten.clang
C:\Ethereum_workspace\siddhuethreuminfuraproject>truffle compile --network ropsten
Compiling your contracts...
===========================
> Compiling .\contracts\Migrations.sol
> Compiling .\contracts\SendMoney.sol
> Artifacts written to C:\Ethereum_workspace\siddhuethreuminfuraproject\build\contracts
> Compiled successfully using:
- solc: 0.8.15+commit.e14f2714.Emscripten.clang
C:\Ethereum_workspace\siddhuethreuminfuraproject>
C:\Ethereum_workspace\siddhuethreuminfuraproject>truffle migrate –network ropsten
Note :- if you get this error
Error message “error:0308010C:digital envelope routines::unsupported”
Here is two option now –
- Try to uninstall Node.js version 17+ and reinstall the Node.js version 16+
You can re install the current LTS node js version from their official site. or more specific downloads from here;
You can use NVM (Node Version Manager)
Linux and Mac users can use this nvm package – https://github.com/nvm-sh/nvm
Windows users can use this nvm package – https://github.com/coreybutler/nvm-windows
- Open terminal and paste these as described :
Linux & Mac OS (windows git bash)-
export NODE_OPTIONS=–openssl-legacy-provider
Windows command prompt-
set NODE_OPTIONS=–openssl-legacy-provider
First install nvm and then execute belwo command.
C:\Users\Siddhartha>nvm use 14.16.0
node v14.16.0 (64-bit) is not installed.
C:\Users\Siddhartha>nvm install 16.17.0
Downloading node.js version 16.17.0 (64-bit)...
Complete
Creating C:\nvm\temp
Downloading npm version 8.15.0... Complete
Installing npm v8.15.0...
Installation complete. If you want to use this version, type
nvm use 16.17.0
C:\Ethereum_workspace\siddhuethreuminfuraproject>set path=C:\nvm\v16.17.0;.;%PATH%
C:\Ethereum_workspace\siddhuethreuminfuraproject>node -v
v16.17.0
C:\Ethereum_workspace\siddhuethreuminfuraproject>nvm use 16.17.0
Now using node v16.17.0 (64-bit)
C:\Ethereum_workspace\siddhuethreuminfuraproject>
If you get this error
Error: There was a timeout while attempting to connect to the network at undefined.Check to see that your provider is valid.
then add this parameter in your truffle-config.js
networkCheckTimeout: 5000000,
Now as we want only our migration script to be uploaded on the test ropsten test environment we are going to use below command.
C:\Ethereum_workspace\siddhuethreuminfuraproject>truffle migrate -f 2 –to 2 –network ropsten –reset
if you get this error
2_SendMoney_migration.js
========================
C:\Ethereum_workspace\siddhuethreuminfuraproject\node_modules\eth-block-tracker\src\polling.js:51
const newErr = new Error(`PollingBlockTracker - encountered an error while attempting to update latest block:\n${err.stack}`)
^
Error: PollingBlockTracker - encountered an error while attempting to update latest block:
undefined
at PollingBlockTracker._performSync (C:\Ethereum_workspace\siddhuethreuminfuraproject\node_modules\eth-block-tracker\src\polling.js:51:24)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
then do the follwing changes
1- instead of using https use wws
new HDWalletProvider(mnemonic, "wss://ropsten.infura.io/ws/v3/be6523b046804030a748c667dee41dbc");
ropsten: {
networkCheckTimeout: 5000000,
provider: function() {
return new HDWalletProvider(mnemonic, "wss://ropsten.infura.io/ws/v3/be6523b046804030a748c667dee41dbc");
},
network_id: 3,// Ropsten's id
gas: 4500000, // Ropsten has a lower block limit than mainnet
gasPrice: 10000000000,
confirmations: 2, // # of confs to wait between deployments. (default: 0)
timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50)
skipDryRun: true // Skip dry run before migrations? (default: false for public nets )
},
C:\Ethereum_workspace\siddhuethreuminfuraproject>truffle migrate -f 2 --to 2 --network ropsten --reset
Compiling your contracts...
===========================
> Compiling .\contracts\Migrations.sol
> Compiling .\contracts\SendMoney.sol
> Artifacts written to C:\Ethereum_workspace\siddhuethreuminfuraproject\build\contracts
> Compiled successfully using:
- solc: 0.8.15+commit.e14f2714.Emscripten.clang
Starting migrations...
======================
C:\Ethereum_workspace\siddhuethreuminfuraproject>truffle compile --all
Compiling your contracts...
===========================
> Compiling .\contracts\Migrations.sol
> Compiling .\contracts\SendMoney.sol
> Artifacts written to C:\Ethereum_workspace\siddhuethreuminfuraproject\build\contracts
> Compiled successfully using:
- solc: 0.8.15+commit.e14f2714.Emscripten.clang
C:\Ethereum_workspace\siddhuethreuminfuraproject>truffle migrate -f 2 --to 2 --network ropsten --reset
Compiling your contracts...
===========================
> Compiling .\contracts\Migrations.sol
> Compiling .\contracts\SendMoney.sol
> Artifacts written to C:\Ethereum_workspace\siddhuethreuminfuraproject\build\contracts
> Compiled successfully using:
- solc: 0.8.15+commit.e14f2714.Emscripten.clang
Starting migrations...
======================
> Network name: 'ropsten'
> Network id: 3
> Block gas limit: 30000000 (0x1c9c380)
2_SendMoney_migration.js
========================
Deploying 'SendMoney'
---------------------
> transaction hash: 0x6bd4153f164c1956e3702f589df53be699ca17bb12387e4fba1f8dac2b054b7b
> Blocks: 2 Seconds: 20
> contract address: 0xB05Ec2761FD10EA72B9583f7e15B287b9CAC01fE
> block number: 12867102
> block timestamp: 1661497944
> account: 0xDD1b4718Ac31cD614a686E5c824c21978412b064
> balance: 9.99343844
> gas used: 328078 (0x5018e)
> gas price: 10 gwei
> value sent: 0 ETH
> total cost: 0.00328078 ETH
Pausing for 2 confirmations...
-------------------------------
> confirmation number: 1 (block: 12867103)
> confirmation number: 2 (block: 12867104)
> Saving artifacts
-------------------------------------
> Total cost: 0.00328078 ETH
Summary
=======
> Total deployments: 1
> Final cost: 0.00328078 ETH
C:\Ethereum_workspace\siddhuethreuminfuraproject>
As soon as the contract is deployed you will see that your account 1 of ropsten ehter will be less as this the fees we paid for our contract deployment on the Roopsten test server. This decrease of the ether is confirmation that our contract is deployed properly.
Now lets check the trasection detail on browser for the deployment of the smart contract.
https://ropsten.etherscan.io/address/0xB05Ec2761FD10EA72B9583f7e15B287b9CAC01fE
you can also find this address of the url from our build folder i.e.
C:\Ethereum_workspace\siddhuethreuminfuraproject\build\contracts
You can also check the infura ui to see the transection done for deployment
https://infura.io/dashboard/stats/ethereum/24h/be6523b046804030a748c667dee41dbc
Now lets try test if our smart contract is working fine on the ropsten environment. For this we are going to use our Remix app.
We will first connect to metamask.
Now lets transfer the amount from remix
Sender address Account1:-0xDD1b4718Ac31cD614a686E5c824c21978412b064
Receiver address- Account2:-0xB63b05b90D69F6667cC316876461c46A861a4300
Now click on the getsenderbalance and getreceiverbalance
Now lets call the sendAmoutn method by passing receiver address and ether amount.
0xB63b05b90D69F6667cC316876461c46A861a4300,1
Hurrey finally we are successful in executing the contract.
So in short we had done following things in this blog
1- we use the frame work of truffle to create a project and used VS Code as code editor.
2- we integrate Ganache UI for test server and integrate it with truffle.
3- We created a smart contract on solidity
4- we tested it on Remix site
4- we tested it on local truffle configured on Ganache Test server data.
5- we tested it on Remix site using Ganache UI as test server.
6- We tested our smart contract on Remix site using Ganache UI as test server and metamask as wallet.(ask for permission to confirm any transection to execute and debit the respective amount from our wallets).
7- we used infura account and its url for connecting to the ropsten network.
8- finally we deploy our smartcontract on the ropsten using infura
9- We tested our smart contract using remix and metamask as wallet.
In next lab we will do following things.
1- we created UI simple html and with the help of web3.js interact with our smart contract exposed on truffle with Ganache ui test server data locally (means not deployed our html on any server localhost direcly opened it on browser and test it for calling smart contract).
2- We exposed our simple ui html on local host using php server and contacted our smart contract deployed/migrated on Truffle using Metamast as wallets
3- Then we installed geth client and made our machine as an ethereum node so that we can upload our contract on Test ehereum block chain.
8- Finally we deployed our smart contract on test env along with ui on swarm and consumed it using browser.
Note:- you can download the code from below location
remix code:- https://github.com/shdhumale/remix-backup-at-18h29min-2022-8-25.git
truffle code:- https://github.com/shdhumale/siddhuethreuminfuraproject.git
No comments:
Post a Comment