Created
July 10, 2021 08:17
-
-
Save himitsu-fushigi/c76a66288dc194bec03a67f3a18ab60c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Here's how we would access our contract: | |
var abi = /* abi generated by the compiler */ | |
var ZombieFactoryContract = web3.eth.contract(abi) | |
var contractAddress = /* our contract address on Ethereum after deploying */ | |
var ZombieFactory = ZombieFactoryContract.at(contractAddress) | |
// `ZombieFactory` has access to our contract's public functions and events | |
// some sort of event listener to take the text input: | |
$("#ourButton").click(function(e) { | |
var name = $("#nameInput").val() | |
// Call our contract's `createRandomZombie` function: | |
ZombieFactory.createRandomZombie(name) | |
}) | |
// Listen for the `NewZombie` event, and update the UI | |
var event = ZombieFactory.NewZombie(function(error, result) { | |
if (error) return | |
generateZombie(result.zombieId, result.name, result.dna) | |
}) | |
function generateZombie(id, name, dna) {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment