Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage instructions are slightly defective (at README.md) #21

Open
mojtaba-eshghie opened this issue Aug 5, 2024 · 1 comment
Open

Comments

@mojtaba-eshghie
Copy link

Hi,

The extract code commands don't work:

(base) mojtabaeshghie@mojtabaeshghie-mbp teether % python bin/extract_contract_code.py test.code > test.contract.code
WARNING:root:No CODECOPY in this contract!!
Traceback (most recent call last):
  File "bin/extract_contract_code.py", line 48, in <module>
    contract = extract_contract_code(code)
  File "bin/extract_contract_code.py", line 18, in extract_contract_code
    p.cfg.trim()
  File "/Users/mojtabaeshghie/.pyenv/versions/3.8.13/lib/python3.8/site-packages/teether-0.1.10-py3.8.egg/teether/project.py", line 45, in cfg
  File "/Users/mojtabaeshghie/.pyenv/versions/3.8.13/lib/python3.8/site-packages/teether-0.1.10-py3.8.egg/teether/cfg/cfg.py", line 12, in __init__
KeyError: 0

My contract source is:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract Test {
    struct Transaction {
        address to;
        uint amount;
    }

    mapping(bytes32 => Transaction) transactions;

    address owner;

    constructor() {
        owner = msg.sender;
    }

    function setOwner(address newOwner) public {
        owner = newOwner;
    }

    function newTransaction(address to, uint amount) public returns (bytes32) {
        bytes32 token = keccak256(abi.encodePacked(to, amount));
        Transaction storage t = transactions[token];
        t.to = to;
        t.amount += amount;
        return token;
    }

    function approve(bytes32 token) public {
        require(owner == msg.sender, "Only the owner can approve transactions");
        Transaction storage t = transactions[token];
        payable(t.to).transfer(t.amount);
        delete transactions[token];
    }

    // Fallback function to receive ether
    receive() external payable {}
}
@nescio007
Copy link
Owner

Hi @mojtaba-eshghie,

could you paste the contents of the file test.code?
It should contain the hex-encoded bytecode of the contract under test, not the Solidity source code.

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

No branches or pull requests

2 participants