box.js 704 B

12345678910111213141516171819202122
  1. import boxAbi from '../config/abi/box.json'
  2. import Web3 from 'web3'
  3. //转账
  4. function payment(myAddress, pid, amount, lpAddress) {
  5. return new Promise(async function (resolve, reject) {
  6. let web3 = new Web3(window.web3.currentProvider);
  7. let crossingOkContractInstance = new web3.eth.Contract(boxAbi, lpAddress);
  8. let hash = ''
  9. crossingOkContractInstance.methods.payment(pid,amount).send({ from: myAddress })
  10. .on('transactionHash', res => {
  11. hash = res
  12. }).on('confirmation', res => {
  13. resolve(hash)
  14. }).on('error', res => {
  15. reject(res)
  16. })
  17. })
  18. }
  19. export default {
  20. payment
  21. }