question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

erc20/library.cairo "Transfer" event param "_from" not compatible with Starknet Python testing library

See original GitHub issue

📝 Details

with Starkware official testing Python package: starkware/starknet/testing/contract_utils.py line 100, it encodes processed StarknetTransaction with namedtuple. Thus, calling erc20 Transfer with current OZ event signature

@event
func Transfer(_from : felt, to : felt, value : Uint256):
end

will fail with ValueError: Field names cannot start with an underscore: '_from'

🔢 Code to reproduce bug

In Python, try calling Transfer with this pattern tx = await erc20_contract.transfer(10, dst.contract_address).invoke(src) given

  • erc20_contract = erc20 contract
  • src = source account contract
  • dst = destination account contract

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
martriaycommented, Mar 19, 2022

Yeah, that’s fair. I suppose ugly is better than potentially confusing.

Agree. Luckily argument names are not part of Ethereum’s ABI specification, so it shouldn’t break anything. I’m unsure about the events though.

Let’s go with from_ then.

1reaction
milancermakcommented, Mar 18, 2022

To me, that looks too much like a type name (when compared to Uint256), but that’s just my opinion.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Shard-Labs/starknet-hardhat-plugin - GitHub
A plugin for integrating StarkNet tools into Hardhat projects - GitHub ... but will default to 'alphaGoerli' network in case this parameter is...
Read more >
Writing unit tests — Cairo documentation - cairo-lang
This page demonstrates how to write unit tests for your StarkNet contracts. The cairo-lang package provides a set of Python classes that simulates...
Read more >
Guide - Starknet.py documentation
Using existing contracts . Although it is possible to use Client to interact with contracts, it requires translating python values into Cairo...
Read more >
Getting started with OpenZeppelin Contracts for Cairo
Using the library. For this example we'll create an ERC20 token. First, create a MyToken.cairo file and write:.
Read more >
Unit tests - Perama's notes.
A contract can be tested before deployment. Below is a contract that stores pen and paper inventory across different warehouses. To test that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found