I just want to deploy and call a simple sample smart contract only for testing purpose. Do I need to download the entire ethereum blockchain? Its too huge and takes too long to download. Can someone suggest a better option?
6 Answers
Ropsten (or Görli/Kovan etc) test network is the right choice for you, when you are still testing.
I simply install the Chrome Metamask plugin. It communicates with nodes on a remote server (so no downloading, though Ropsten is not as big as the main chain anyway)
Create a new account after switching to the Ropsten network.
Then you can use the Online Solidity Compiler to deploy the contract, like this:
Top left corner, under Run > Environment, check the 2nd option "injected Web3"
With "Create", you can deploy your contract and Metamask will ask you for your password.
Now you are able to test your contract using the provided interface.
You can also get your smart contracts in the "details" and use it in an application.
Choosing the 1st option "JavaScript VM" will achieve a similar experience but will not actually deploy anything on the network.
-
I use Remix with this approach too. It's very straightforward for beginner, but when I get to know more in Ethereum, I may go for Truffle way, which provide a automatic way for unit-testing Commented Jul 17, 2018 at 7:33
Truffle is a development environment, testing framework and asset pipeline for Ethereum, aiming to make life as an Ethereum developer easier. With Truffle, you get:
- Built-in smart contract compilation, linking, deployment and binary management.
- Automated contract testing with Mocha and Chai.
- Configurable build pipeline with support for custom build processes.
- Scriptable deployment & migrations framework.
- Network management for deploying to many public & private networks.
- Interactive console for direct contract communication.
- Instant rebuilding of assets during development.
- External script runner that executes scripts within a Truffle environment.
-
-
1You could use the ethereumjs-testrpc along with truffle to not have to download the whole thing: github.com/ethereumjs/testrpc Commented Jan 18, 2017 at 15:51
-
this is unrelated but, do you guys know how I can call a contract that's been deployed to ropsten, for instance, this one: ethereum.stackexchange.com/questions/23344/… Commented Jul 30, 2017 at 20:54
You can use Populus (Python based) framework for smart contract development and testing. It comes with standard py.test based unit tests for smart contracts.
It includes
Test using TestRPC (instant transactions) or private testnet - no slow blokchain syncing
Built-in smart contract compilation, linking, deployment and binary management.
Scriptable deployment & migrations framework.
Network management for deploying to many public & private networks.
Interactive console for direct contract communication from Python prompt
Instant rebuilding of assets during development
External script runner that executes scripts within a Populus environment (simply do Python import)
Benefits over JavaScript approaches include
Cleaner test code - no callback hell (example)
More readable test by using
assert
keyword instead of various equality functions
Ethereum Wallet: You don't need to download the entire ETH blockchain to use testnet. The Ethereum Wallet is an easy way to deploy contracts on test networks. I would recommend the Rinkeby testnet.
Download and Launch the Wallet https://github.com/ethereum/mist/releases
Click DEVELOP>SYNC WITH LIGHT CLIENT
Click DEVELOP>NETWORK>RINKEBY
Get TestNet Ether: https://faucet.rinkeby.io/
On the Ethereum Wallet Client, click 'CONTRACTS' > 'DEPLOY NEW CONTRACT'
A simple and straight forward command line tool for testing Ethereum smart contracts - Ethester. It has minimum of software deps: Python 2.7, Ethereum. Solidity compiler suggested but not required.