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

[STABLE-2112]: add example script #5

Merged
merged 9 commits into from
Jan 11, 2023

Conversation

hsinghgrewal
Copy link
Contributor

@hsinghgrewal hsinghgrewal commented Jan 6, 2023

Summary

Add a example script to get started with CCTP. The script use web3.js transfer USDC from eth testnet address to avax testnet address.

examples/index.html Outdated Show resolved Hide resolved
examples/index.html Outdated Show resolved Hide resolved
examples/index.html Outdated Show resolved Hide resolved
examples/index.html Outdated Show resolved Hide resolved
examples/index.html Outdated Show resolved Hide resolved
examples/index.html Outdated Show resolved Hide resolved
examples/index.html Outdated Show resolved Hide resolved
examples/index.html Outdated Show resolved Hide resolved
examples/index.html Outdated Show resolved Hide resolved
examples/index.html Outdated Show resolved Hide resolved
examples/index.html Outdated Show resolved Hide resolved
examples/index.html Outdated Show resolved Hide resolved
examples/index.html Outdated Show resolved Hide resolved
examples/index.html Outdated Show resolved Hide resolved
@hsinghgrewal hsinghgrewal marked this pull request as ready for review January 10, 2023 00:02
Copy link
Contributor

@walkerq walkerq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just a few minor comments.

examples/abis/Message.json Outdated Show resolved Hide resolved
examples/index.js Outdated Show resolved Hide resolved
const avaxMessageTransmitterContract = new ethers.Contract(AVAX_MESSAGE_TRANSMITTER_CONTRACT_ADDRESS, messageTransmitterAbi, signer);

// AVAX destination address
const mintRecipient = "<YOUR_AVAX_ADDRESS>";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be paramaterized?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean as a env variable. I don't think we can do that with html script

Comment on lines 29 to 34
// const approveTx = await usdcEthContract.approve(TOKEN_MESSENGER_CONTRACT_ADDRESS, 500000) // 0.5 USDC
// console.log(`ApproveTx: ${approveTx.hash}`)

// Wait for transaction to complete
// const approveTxReceipt = await provider.waitForTransaction(approveTx.hash)
// console.log(`ApproveTxReceipt: ${approveTxReceipt}`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metamask ask before burn tx even if we approve

docs/README.md Outdated Show resolved Hide resolved
docs/README.md Outdated Show resolved Hide resolved
docs/README.md Outdated Show resolved Hide resolved
docs/README.md Outdated Show resolved Hide resolved
docs/README.md Outdated Show resolved Hide resolved
walkerq
walkerq previously approved these changes Jan 10, 2023
Copy link
Contributor

@walkerq walkerq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

docs/README.md Outdated Show resolved Hide resolved
docs/README.md Outdated
The script has 5 steps:
1. First step approves `ETH_TOKEN_MESSENGER_CONTRACT_ADDRESS` to withrdraw USDC from our eth address.
```js
const approveTx = await usdcEthContract.methods.approve(ETH_TOKEN_MESSENGER_CONTRACT_ADDRESS, amount+1).send({gas: approveTxGas})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why amount + 1?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also show the usdcEthContract instantiation here in the steps? Or just leave it for the actual script?
And other contract instantiations below

Copy link
Contributor Author

@hsinghgrewal hsinghgrewal Jan 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why amount + 1?

no reason. As long as the approve amount >= withdraw amount it should be good. I'll remove the +1

Copy link
Contributor Author

@hsinghgrewal hsinghgrewal Jan 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also show the usdcEthContract instantiation here in the steps? Or just leave it for the actual script?
And other contract instantiations below

Just to keep it minimal and not be repetitive, I am just describing the actual function that gets in README. wdyt?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think that's fine. Can you add a note at the top then saying these are snippets and link to the fully functioning code?

docs/index.js Outdated Show resolved Hide resolved
Copy link

@chasemcdermott chasemcdermott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks awesome, couple small things!

docs/README.md Outdated Show resolved Hide resolved
docs/README.md Outdated
The script has 5 steps:
1. First step approves `ETH_TOKEN_MESSENGER_CONTRACT_ADDRESS` to withrdraw USDC from our eth address.
```js
const approveTx = await usdcEthContract.methods.approve(ETH_TOKEN_MESSENGER_CONTRACT_ADDRESS, amount+1).send({gas: approveTxGas})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also show the usdcEthContract instantiation here in the steps? Or just leave it for the actual script?
And other contract instantiations below

docs/README.md Outdated Show resolved Hide resolved
docs/README.md Outdated Show resolved Hide resolved
@hsinghgrewal hsinghgrewal merged commit d1c2457 into circlefin:master Jan 11, 2023
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

Successfully merging this pull request may close these issues.

3 participants