Skip to content

Instantly share code, notes, and snippets.

@himitsu-fushigi
Created July 10, 2021 08:17
Show Gist options
  • Save himitsu-fushigi/c76a66288dc194bec03a67f3a18ab60c to your computer and use it in GitHub Desktop.
Save himitsu-fushigi/c76a66288dc194bec03a67f3a18ab60c to your computer and use it in GitHub Desktop.
// 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