Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

[EVM] A precompile contrate to transfer the balance from the EVM account to the substrate account. #319

Closed
wuminzhe opened this issue Oct 10, 2020 · 5 comments

Comments

@wuminzhe
Copy link
Contributor

Question: Is it necessary to reconstruct the input format included FROM, TO, VALUE to adapt to Trait Precompile?

@wuminzhe
Copy link
Contributor Author

call from solidity:

impl Precompile for TransferBack {

pragma solidity ^0.6.0;

contract Test1 {

  function transferBack() public view {
    bytes32[3] memory output;
    bytes32[3] memory h;
    h[0] = hex"000000000000000000000000182c00A789A7cC6BeA8fbc627121022D6029a416";
    h[1] = hex"d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d";
    h[2] = hex"0000000000000000000000000000000000000000000000000000000000221388";
    // h[3] = sign
    bytes memory input = abi.encodePacked(h[0], h[1], h[2]);
    assembly {

      if iszero(staticcall(not(0), 0x1, input, 0x80, output, 0x40)) {
        revert(0, 0)
      }
    }
  }
}

https://github.com/ethereum/EIPs/blob/master/EIPS/eip-152.md#example-usage-in-solidity

@wuminzhe wuminzhe changed the title A precompile contrate to transfer the balance from the EVM account to the substrate account. [evm] A precompile contrate to transfer the balance from the EVM account to the substrate account. Oct 15, 2020
@wuminzhe wuminzhe changed the title [evm] A precompile contrate to transfer the balance from the EVM account to the substrate account. [EVM] A precompile contrate to transfer the balance from the EVM account to the substrate account. Oct 15, 2020
@boundless-forest
Copy link
Member

#334

@aurexav
Copy link
Member

aurexav commented Nov 3, 2020

Can close now? #334 merged.

@WoeOm
Copy link

WoeOm commented Jan 13, 2021

// h[3] = sign
Why is there no need to verify the signature?
@wuminzhe

@boundless-forest
Copy link
Member

Pre-compiled contracts do not have access to the from values of transactions and cannot resist relay attacks, so this solution is abandoned.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants