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

KIP-0032: Cross-Chain Function Call Syntax Enhancement #65

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

DaisukeFlowers
Copy link

@DaisukeFlowers DaisukeFlowers commented Nov 5, 2024

This KIP proposes a syntax enhancement for Pact that enables specifying the chain ID within function calls to facilitate direct cross-chain interactions. By including the chain ID in function calls, we aim to simplify and expand cross-chain workflows, reducing reliance on yield/resume constructs for data transfer only. This will allow contracts to directly interact across chains, improving developer efficiency and usability for complex multi-chain operations.

Looking forward to feedback and any suggestions on refining the proposal!


@DaisukeFlowers DaisukeFlowers changed the title Create KPI-0029 draft KIP-0032: Cross-Chain Function Call Syntax Enhancement Nov 5, 2024

## Motivation

Kadena's current cross-chain communication utilizes `defpact`, `yield`, and `resume` constructs to transfer data between chains. While effective for data exchange, this approach is limited and can become complex for developers who need to execute functions or retrieve information from other chains directly.
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @DaisukeFlowers, I'm rewording this a bit to make sure I understand the main ask:

  • Is this asking for smart contracts to call functions in other chains?
  • This would be similar to how smart contracts can currently call functions in other smart contracts within the same chain, correct?

Copy link
Contributor

@LindaOrtega LindaOrtega Nov 5, 2024

Choose a reason for hiding this comment

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

Example of reading the state in another chain:
Let say the following Pact code is being executed on Chain 0:

(free.token.get-balance ACCOUNT_A)
(1.free.token.get-balance ACCOUNT_A)

(free.token.get-balance ACCOUNT_A) will retrieve the account balance of ACCOUNT_A in Chain 0.
But (1.free.token.get-balance ACCOUNT_B) will retrieve the account balance of ACCOUNT_A in Chain 1.

Example of changing the state in another chain:
Let say the following Pact code is being executed on Chain 0:

(2.free.token.transfer ACCOUNT_A ACCOUNT_B 2.5)
(free.someOtherToken.transfer ACCOUNT_B ACCOUNT_A 1.0)

(2.free.token.transfer ACCOUNT_A ACCOUNT_B 2.5) will transfer funds from these accounts on chain 2.
(free.someOtherToken.transfer ACCOUNT_B ACCOUNT_A 1.0) will transfer funds from these accounts on chain 0.


aka, being able to execute a Pact function on Chain 2 while executing other code in Chain 0, for example.
Are these interpretations correct?

Copy link
Author

@DaisukeFlowers DaisukeFlowers Nov 6, 2024

Choose a reason for hiding this comment

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

Hi @LindaOrtega, all statements are correct.
The function will be executed as if on the target chain.
In the last example:
If the following is executed on chain 0
(2.free.token.transfer ACCOUNT_A ACCOUNT_B 2.5)
ACCOUNT_A from chain 2 will transfer to ACCOUNT_B from chain 2.
The function will be executed as if in chain 2 from chain 0.

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.

2 participants