Dapp Assignment 1

Post your solutions to the remove dog assignment here.

I first checked how it works from the terminal and checked the cpp contract.
cleos push action dogcontract erase ‘[4]’ -p medosync

executed transaction: 6bcf1968898b9f8f428a56a8a99de3a39b679b6a11af957cba1883688edf3f02 96 bytes 257 us
'# dogcontract <= dogcontract::erase {“dog_id”:4}
warning: transaction executed locally, but may not be confirmed by the network yet ]

<div class="row">
    <div class="col">
      <h2>Remove Dog</h2>
      <div>
        <label>Dog Number:</label>
        <input type="number" id="dog_id">
      </div>
      <button type="button" id="remove_dog_button" class="bth btn-secondary">Remove Dog</button>
    </div>
  </div>

function removeDog(){

var dogNumber = $("#dog_id").val();
eos.transact({
actions: [{
account: contractConfig.code,
name: ‘erase’,
authorization: [{
actor: account.name,
permission: account.authority
}],
data: {
dog_id: dogNumber
}
}]
}, {
blocksBehind: 3,
expireSeconds: 30
}).then(function(res){
console.log(res);
//Transaction successful Add Dog
getDogs();
}).catch(function(err){
alert(err);
})
}

1 Like