This school project is the blockchain part of a ticket manager for JO 2024. There is a bonus web application to show how to call your blockchain contract.
It's a good minimalist example of what can be done with solidity and web3js.
First you need to have some packages installed:
-
npm (needed for solidity dependencies)
-
yarn (optional if you want to use yarn instead of npm to install packages of app)
-
expo (needed to launch the app)
Ganache is needed to create a private blockchain. It allows you to deploy your contracts in a local environment.
Install it :
npm install ganache ganache-cli ganache-core --global
Truffle is needed to build your contracts and deploy them on any blockchain.
Install it :
npm install truffle --global
First, you need to launch a private blockchain locally.
ganache-cli
something like this is displayed :
Then, you can modify the file truffle-config.js
with your own configurations.
Deploy your contract : (You don't need to build your contracts, this command do it for you)
truffle deploy --network [network_name]
# truffle deploy --network development
the network_name
parameter is the name of your network in the truffle-config.js
, in the networks section. (for example development
)
You will get something like that :
contract address
, keep it somewhere.
First, you need to get the built contract informations:
cp build/contracts/TicketFactory.json app/utils/TicketFactory.json
Modify the TicketFactoryAddress
variable in the file app/App.js
. (this value is the contract address
given by the truffle command)
Go to app folder and install dependencies
cd app
expo install
# OR yarn install
# OR npm install
Start the application
expo start
# OR yarn start
# OR npm start
You can now go to your application at the url given by expo