Skip to content
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
245 changes: 245 additions & 0 deletions packages/passport/sdk-sample-app/get-transaction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
import * as ethers from "ethers";

const erc20Abi = [
{
"constant": true,
"inputs": [],
"name": "name",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_spender",
"type": "address"
},
{
"name": "_value",
"type": "uint256"
}
],
"name": "approve",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "totalSupply",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_from",
"type": "address"
},
{
"name": "_to",
"type": "address"
},
{
"name": "_value",
"type": "uint256"
}
],
"name": "transferFrom",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "decimals",
"outputs": [
{
"name": "",
"type": "uint8"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "_owner",
"type": "address"
}
],
"name": "balanceOf",
"outputs": [
{
"name": "balance",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "symbol",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_to",
"type": "address"
},
{
"name": "_value",
"type": "uint256"
}
],
"name": "transfer",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "_owner",
"type": "address"
},
{
"name": "_spender",
"type": "address"
}
],
"name": "allowance",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"payable": true,
"stateMutability": "payable",
"type": "fallback"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "owner",
"type": "address"
},
{
"indexed": true,
"name": "spender",
"type": "address"
},
{
"indexed": false,
"name": "value",
"type": "uint256"
}
],
"name": "Approval",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "from",
"type": "address"
},
{
"indexed": true,
"name": "to",
"type": "address"
},
{
"indexed": false,
"name": "value",
"type": "uint256"
}
],
"name": "Transfer",
"type": "event"
}
]

async function main() {
const provider = new ethers.JsonRpcProvider("https://sepolia-rollup.arbitrum.io/rpc");

const wallet = ethers.Wallet.fromPhrase("attract chase stool practice orphan version bargain spin crisp often chuckle auction save own exclude", provider);
console.log(wallet.address);

const sender = "0x1d11a5c0adf049a5ab706cbaae78d681e25bbe62";
const usdc = new ethers.Contract("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d", erc20Abi, provider);

console.log(await usdc.balanceOf(sender));

console.log(await usdc.approve.estimateGas("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d", 100, { from: sender }))

const transferTx = usdc.interface.encodeFunctionData("approve", ["0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d", 100]);

console.log({ transferTx });
}

main();

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import React, { useState } from 'react';
import { Stack } from 'react-bootstrap';
import { usePassportProvider } from '@/context/PassportProvider';
import Request from '@/components/arbitrum/Request';
import CardStack from '@/components/CardStack';
import { useStatusProvider } from '@/context/StatusProvider';
import WorkflowButton from '@/components/WorkflowButton';

function ArbitrumWorkflow() {
const [showRequest, setShowRequest] = useState<boolean>(false);

const { isLoading } = useStatusProvider();
const { connectArbitrum, arbitrumProvider } = usePassportProvider();

const handleRequest = () => {
setShowRequest(true);
};

return (
<CardStack title="Arbitrum One Workflow">
<Stack direction="horizontal" style={{ flexWrap: 'wrap' }} gap={3}>
{arbitrumProvider && (
<>
<WorkflowButton
disabled={isLoading}
onClick={handleRequest}
>
request
</WorkflowButton>
{showRequest && (
<Request
showModal={showRequest}
setShowModal={setShowRequest}
/>
)}
</>
)}
{!arbitrumProvider && (
<WorkflowButton
disabled={isLoading}
onClick={connectArbitrum}
>
Connect Arbitrum
</WorkflowButton>
)}
</Stack>
</CardStack>
);
}

export default ArbitrumWorkflow;
Loading
Loading