Closed infra403 closed 1 year ago
Hello, I think that you should improve your understanding of the Starknet architecture, because you have some confusions about some definitions : The ETH contract is behind a proxy. So you have to understand how it works : A class hash : https://docs.starknet.io/documentation/architecture_and_concepts/Contracts/contract-classes/ A contract address : https://docs.starknet.io/documentation/architecture_and_concepts/Contracts/contract-address/
So,
getClassAt()
to have the abi of the proxy.getClassByHash()
to have the abi of the ERC20 contract.In case of such problem, do not hesitate to contact us in our Discord : https://discord.com/channels/793094838509764618/927918707613786162
Hello, I think that you should improve your understanding of the Starknet architecture, because you have some confusions about some definitions : The ETH contract is behind a proxy. So you have to understand how it works : A class hash : https://docs.starknet.io/documentation/architecture_and_concepts/Contracts/contract-classes/ A contract address : https://docs.starknet.io/documentation/architecture_and_concepts/Contracts/contract-address/
So,
- You have first to use
getClassAt()
to have the abi of the proxy.- Then call the function that provide the implemented class hash.
- Use
getClassByHash()
to have the abi of the ERC20 contract.- You create the contract instance with the address of the proxy and the abi of the class implemented.
- Finally, you can use call/invoke to interact with the ERC20.
In case of such problem, do not hesitate to contact us in our Discord : https://discord.com/channels/793094838509764618/927918707613786162
good work!
Adding it to the official documentation would be best @PhilippeR26
The guide explaining how to create a ArgentX account is based on this principle : https://www.starknetjs.com/docs/next/guides/create_account#create-an-argent-account
Closing as "not-a-bug" @PhilippeR26 resolved the question
Hello, I think that you should improve your understanding of the Starknet architecture, because you have some confusions about some definitions : The ETH contract is behind a proxy. So you have to understand how it works : A class hash : https://docs.starknet.io/documentation/architecture_and_concepts/Contracts/contract-classes/ A contract address : https://docs.starknet.io/documentation/architecture_and_concepts/Contracts/contract-address/
So,
- You have first to use
getClassAt()
to have the abi of the proxy.- Then call the function that provide the implemented class hash.
- Use
getClassByHash()
to have the abi of the ERC20 contract.- You create the contract instance with the address of the proxy and the abi of the class implemented.
- Finally, you can use call/invoke to interact with the ERC20.
In case of such problem, do not hesitate to contact us in our Discord : https://discord.com/channels/793094838509764618/927918707613786162
Based on the code below, the address I obtained is 0x58c891da6c3b1ed062db42db3c6ca080724fabbe3d5073660d02aab8edc3e95, but the expected address is 0x48624e084dc68d82076582219c7ed8cb0910c01746cca3cd72a28ecfe07e42d. What could be the issue?
javascript Copy code const ethAddress = '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7'; const ethHashAddress = "0x00d0e183745e9dae3e4e78a8ffedcce0903fc4900beace4e0abf192d4c202da3"; const contractClass = await provider.getClassAt(ethAddress); const classContract = new Contract(contractClass.abi, ethAddress, provider); const {address: implAddress} = await classContract.implementation(); console.log("impl address", implAddress.toString(16));
As it's not related to a Starknet.js bug or proposal of improvement, could you please use Discord media :
As it's not related to a Starknet.js bug or proposal of improvement, could you please use Discord media :
I don't have permission to access this link.
So, register in Discord : https://discord.com/ Then to Starknet Discord : https://discord.gg/qypnmzkhbc
So, register in Discord : https://discord.com/ Then to Starknet Discord : https://discord.gg/qypnmzkhbc
I just registered an account and cannot accept the invitation.. Error: code: 40007 message: 该用户已被此服务器封禁.
Describe the bug
The account balance is showing as zero, however, through ArgentX I can see that the account has a balance.
The address of the proxy contract implementation obtained through the API is incorrect.
To Reproduce
The account balance is showing as zero, however, through ArgentX I can see that the account has a balance.
`address = '0x065934Da171A56d0aee41866C656b89ddbD5653C44F49331803dAAA052d1aCCE' const ethAddress = '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7' const contractClass = await provider.getClassAt(ethAddress) const ethAbi = json.parse(JSON.stringify(contractClass.abi)) const erc20 = new Contract(compileERC20.abi, ethAddress, provider); const balanceAfterTransfer = await erc20.balanceOf(address); const result = weiEthToEth(uint256.uint256ToBN(balanceAfterTransfer.balance).toString()) console.log("balance", result);
`
The address of the proxy contract implementation obtained through the API is incorrect.
` const contractClassHash = await provider.getClassHashAt(tokenAddr) console.log("contractClassHash", contractClassHash) const {abi: testAbi} = await provider.getClassByHash(contractClassHash) const testContract = new Contract(testAbi, tokenAddr, provider); const {address: testAddress} = await testContract.implementation() console.log("testAddress", testAddress)
const {abi: classAbi} = await provider.getClassAt(tokenAddr) const erc20Class = await new Contract(classAbi, tokenAddr, account); const {address: implAddress} = await erc20Class.implementation() console.log("implAddress", implAddress, toHex(implAddress), tokenAddr) // get implementation address: 0x58c891da6c3b1ed062db42db3c6ca080724fabbe3d5073660d02aab8edc3e95 // real address: 0x048624e084dc68d82076582219c7ed8cb0910c01746cca3cd72a28ecfe07e42d
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context Add any other context about the problem here.