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

docs: update readme for zkevm functions and update sample app labels #94

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 59 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,41 +105,6 @@ catch (Exception)
await passport.Logout();
```

### Immutable X Transfer

> Note: The transfers feature require pre-approval from Immutable. Please reach out to us before making use of it.

An unsigned transfer request for ETH, ERC20 or ERC721 is expected for the ImxTransfer method.

```csharp
UnsignedTransferRequest request = UnsignedTransferRequest.ERC721(
receiver,
tokenId,
tokenAddress
);

CreateTransferResponseV1 response = await passport.ImxTransfer(request);
```

Batch NFT transfers are also supported:

```csharp
NftTransferDetails[] details = {
new NftTransferDetails(
receiver1,
tokenId1,
tokenAddress1
),
new NftTransferDetails(
receiver2,
tokenId2,
tokenAddress2
)
};

CreateBatchTransferResponse response = await passport.ImxBatchNftTransfer(details);
```

### Android, iOS and macOS PKCE login

For Android and iOS you can use the PKCE login flow instead of Device Code. This means the gamer has one less step to complete and will be redirected back to the game after successfully authenticating.
Expand Down Expand Up @@ -188,6 +153,62 @@ After this set-up, your game can log in using PKCE.

After this set-up, your game can log in using PKCE.

### Immutable X Transfer

> Note: The transfers features require pre-approval from Immutable. Please reach out to us before making use of it.

An unsigned transfer request for ETH, ERC20 or ERC721 is expected for the ImxTransfer method.

```csharp
UnsignedTransferRequest request = UnsignedTransferRequest.ERC721(
receiver,
tokenId,
tokenAddress
);

CreateTransferResponseV1 response = await passport.ImxTransfer(request);
```

Batch NFT transfers are also supported:

```csharp
NftTransferDetails[] details = {
new NftTransferDetails(
receiver1,
tokenId1,
tokenAddress1
),
new NftTransferDetails(
receiver2,
tokenId2,
tokenAddress2
)
};

CreateBatchTransferResponse response = await passport.ImxBatchNftTransfer(details);
```

### zkEVM Send Transaction

> Note: The zkEVM send transaction feature requires pre-approval from Immutable. Please reach out to us before making use of it.

- `To`: The destination address
- `Value`: The value to transfer for the transaction in wei
- `Data`: Byte string containing the associated data of the message

```csharp
TransactionRequest request = new TransactionRequest()
{
To = address,
Value = amount,
Data = data
}

string? transactionHash = await passport.ZkEvmSendTransaction(request);
```

See [here](https://docs.immutable.com/docs/zkEVM/products/passport/wallet/rpc-methods/eth_sendTransaction) for more details.

## Supported Functions

- Get wallet address
Expand All @@ -197,6 +218,9 @@ After this set-up, your game can log in using PKCE.
- Checks if there are any credentials saved
- Immutable X Transfer (ERC20, ETH and ERC721)
- Immutable X NFT Batch Transfer
- zkEVM Request Accounts
- zkEVM Get balance
- zkEVM Send transaction

## Examples

Expand Down
38 changes: 19 additions & 19 deletions sample/Assets/Scenes/AuthenticatedScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -1981,7 +1981,7 @@ GameObject:
- component: {fileID: 455311494}
- component: {fileID: 455311493}
m_Layer: 5
m_Name: Amount
m_Name: Value
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
Expand All @@ -2004,8 +2004,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 116, y: -123}
m_SizeDelta: {x: 200, y: 30}
m_AnchoredPosition: {x: 66, y: -123}
m_SizeDelta: {x: 100, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &455311493
MonoBehaviour:
Expand Down Expand Up @@ -2418,7 +2418,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Amount...
m_Text: Value...
--- !u!222 &548681578
CanvasRenderer:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -2622,8 +2622,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 116, y: -77}
m_SizeDelta: {x: 200, y: 30}
m_AnchoredPosition: {x: 66, y: -77}
m_SizeDelta: {x: 100, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &563057549
MonoBehaviour:
Expand Down Expand Up @@ -2919,7 +2919,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 332, y: -77}
m_AnchoredPosition: {x: 232, y: -77}
m_SizeDelta: {x: 200, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &649013319
Expand Down Expand Up @@ -6331,8 +6331,8 @@ MonoBehaviour:
zkGetBalanceAccount: {fileID: 885231615}
zkSendTransactionCanvas: {fileID: 1343113126}
zkSendTransactionTo: {fileID: 649013321}
zkSendTransactionAmount: {fileID: 1901422923}
zkSendTransactionFunctionSignature: {fileID: 1391622483}
zkSendTransactionValue: {fileID: 1901422923}
zkSendTransactionData: {fileID: 1391622483}
--- !u!1 &1216631573
GameObject:
m_ObjectHideFlags: 0
Expand All @@ -6345,7 +6345,7 @@ GameObject:
- component: {fileID: 1216631576}
- component: {fileID: 1216631575}
m_Layer: 5
m_Name: Function signature
m_Name: Data
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
Expand All @@ -6368,8 +6368,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 116, y: -169}
m_SizeDelta: {x: 200, y: 30}
m_AnchoredPosition: {x: 66, y: -169}
m_SizeDelta: {x: 100, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1216631575
MonoBehaviour:
Expand Down Expand Up @@ -6404,7 +6404,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: 'Function signature:'
m_Text: 'Data:'
--- !u!222 &1216631576
CanvasRenderer:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -7071,7 +7071,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: 0x...
m_Text: Data...
--- !u!222 &1349875448
CanvasRenderer:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -7280,7 +7280,7 @@ GameObject:
- component: {fileID: 1391622485}
- component: {fileID: 1391622483}
m_Layer: 5
m_Name: Function signature Input
m_Name: Data Input
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
Expand Down Expand Up @@ -7373,7 +7373,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 332, y: -168.10004}
m_AnchoredPosition: {x: 232, y: -168.10004}
m_SizeDelta: {x: 200, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1391622485
Expand Down Expand Up @@ -9717,7 +9717,7 @@ GameObject:
- component: {fileID: 1901422921}
- component: {fileID: 1901422923}
m_Layer: 5
m_Name: Amount Input
m_Name: Value Input
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
Expand All @@ -9742,7 +9742,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 332, y: -123}
m_AnchoredPosition: {x: 232, y: -123}
m_SizeDelta: {x: 200, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1901422921
Expand Down Expand Up @@ -11203,7 +11203,7 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 1335469792}
m_HandleRect: {fileID: 1335469791}
m_Direction: 2
m_Value: 0
m_Value: 1
m_Size: 1
m_NumberOfSteps: 0
m_OnValueChanged:
Expand Down
12 changes: 6 additions & 6 deletions sample/Assets/Scripts/AuthenticatedScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public class AuthenticatedScript : MonoBehaviour
// ZkEVM Send Transaction
[SerializeField] private Canvas zkSendTransactionCanvas;
[SerializeField] private InputField zkSendTransactionTo;
[SerializeField] private InputField zkSendTransactionAmount;
[SerializeField] private InputField zkSendTransactionFunctionSignature;
[SerializeField] private InputField zkSendTransactionValue;
[SerializeField] private InputField zkSendTransactionData;

private Passport passport;
#pragma warning restore CS8618
Expand Down Expand Up @@ -227,8 +227,8 @@ public async void SendZkTransaction()
string? response = await passport.ZkEvmSendTransaction(new TransactionRequest()
{
To = zkSendTransactionTo.text,
Value = zkSendTransactionAmount.text,
Data = zkSendTransactionFunctionSignature.text
Value = zkSendTransactionValue.text,
Data = zkSendTransactionData.text

});
ShowOutput($"Transaction hash: {response}");
Expand All @@ -244,8 +244,8 @@ public void ShowZkSendTransaction()
authenticatedCanvas.gameObject.SetActive(false);
zkSendTransactionCanvas.gameObject.SetActive(true);
zkSendTransactionTo.text = "";
zkSendTransactionAmount.text = "";
zkSendTransactionFunctionSignature.text = "";
zkSendTransactionValue.text = "";
zkSendTransactionData.text = "";
}

public void CancelZkSendTransaction()
Expand Down
Loading