This project demonstrates interaction with an Ethereum smart contract using the Web3 library and Node.js. It includes functionalities to connect to a local Ethereum blockchain, subscribe to pending transactions, fetch the creator's address of a smart contract, and listen to the 'Transfer' event.
The project showcases how to use the Web3 library to interact with an Ethereum smart contract. It includes sample code to connect to a local Ethereum blockchain, subscribe to pending transactions, fetch the creator's address of a smart contract, and listen to the 'Transfer' event and buy the desired Token
before the targeted wallet
Before using this project, ensure you have the following prerequisites installed:
- Node.js: Download Node.js
-
Clone the repository:
git clone https://github.com/PrantaDas/mint-an-nft.git
-
Change to the project directory:
cd mint-an-nft
-
Install dependencies:
npm install or yarn
-
Set up your Ethereum blockchain (e.g., Ganache) and update the WebSocket provider address in the
web3
initialization:const web3 = new Web3('ws://your-ethereum-node-ip:7545');
-
Specify the contract address and ABI in the
abi.json
file and update the.env
file with the contract address and default wallet address. -
Customize the
wallet
variable with the desired wallet address. -
Run the script:
node index.js
getContractCreatorAddress()
: Fetch the creator's address of the smart contract.- Subscription to pending transactions.
- Logging transaction data and executing the mint function if the transaction is from a specified wallet.
- Subscription to the 'Transfer' event of the smart contract.
Check the examples
directory for usage examples and sample scripts.
Feel free to contribute to the project by opening issues or submitting pull requests. Please adhere to the Code of Conduct.