GetScatter / ScatterWebExtension

Extension that allows you to sign transactions with your private keys securely from within the browser without ever exposing them.
MIT License
367 stars 127 forks source link

How to call contract push action? #176

Closed fundurian closed 5 years ago

fundurian commented 5 years ago

Hello, I am trying to build a website that allow user to sign in with scatter, and then user can click "hirehero" and then it will push the transaction into my eos smart contract , however I do not know how to do it properly as there are lack of example

I normally interact with the smart contract using cleos command as below cleos push action testcontract hirehero '{"user":"useraaa", "type":1}' -p useraaa

So when putting it into the website, i have successfully sign in with scatter, my code as below

function hirehero() { const account = scatter.identity.accounts.find(x => x.blockchain === 'eos'); eos.transaction( { actions: [ { account: 'testcontract', name: 'hirehero', authorization: [{ actor: account, permission: 'active' }], data: { user: account, type: 1

    }
  }
]

} , (error,result)=>{console.log(error,result)} );

}

when i run it, it keep saying TypeError: name parameter is a required string, anything i missing?

fundurian commented 5 years ago

nvm, i found that the error is causing by i need to put "account.name" instead of "account" as my parameter