Skip to content

Commit

Permalink
Add recipient address
Browse files Browse the repository at this point in the history
  • Loading branch information
vivekjain23 committed Dec 23, 2024
1 parent 8c5b717 commit 8a2e901
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
5 changes: 4 additions & 1 deletion docs/content/developer/iota-move-ctf/challenge_0.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ Alternatively, you can use the testnet explorer to call the module's function di
## Deployed Package Address:

```
Package Address: 0x972f3cfc6a824a319485a8c7e9e8bc0ad845e1682d277c6b4d10b5c9511685d7
Package Address: 0x649884331fa662235b2c06c6eb488e5327105dded1331f6b7541ef4fdbd9eeca
```

## Leap Frog NFT Module:

```move file=<rootDir>/docs/examples/move/ctf/challenge_0/sources/leap_frog_nft.move
```

Good luck in capturing your first flag!


<MintLeapFrogNFT/>
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ module leapFrog::leap_frog_nft {
name: vector<u8>,
description: vector<u8>,
url: vector<u8>,
recipient: address,
ctx: &mut TxContext
) {
let sender = tx_context::sender(ctx);
Expand All @@ -48,7 +49,7 @@ module leapFrog::leap_frog_nft {
name: nft.name,
});

transfer::public_transfer(nft, sender);
transfer::public_transfer(nft, recipient);
}

public fun transfer(
Expand Down
29 changes: 22 additions & 7 deletions docs/site/src/components/CTF/mint-leap-frog-nft.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const MintLeapFrogNFT: React.FC = () => {
name:'',
description:'',
url:'',
address:''
});
const [coins, setCoins] = useState<string | null>(null);
const [showPopup, setShowPopup] = useState<boolean>(false);
Expand Down Expand Up @@ -52,8 +53,9 @@ const MintLeapFrogNFT: React.FC = () => {
};

return (
<div>
<div className="flex items-center">
<div className='bg-[#e5e5e5] dark:bg-[#1e1e1e] p-4 rounded-lg'>
<div className="flex flex-col items-start">
<label htmlFor="name">Name <span className="red">*</span></label>
<input
type="text"
value={nft.name}
Expand All @@ -62,8 +64,9 @@ const MintLeapFrogNFT: React.FC = () => {
name:e.target.value
}))}
placeholder="Enter name"
className="input-field mr-2"
className="input-field mb-4"
/>
<label htmlFor="description">Description <span className="red">*</span></label>
<input
type="text"
value={nft.description}
Expand All @@ -72,8 +75,9 @@ const MintLeapFrogNFT: React.FC = () => {
description:e.target.value
}))}
placeholder="Enter description"
className="input-field mr-2"
className="input-field mb-4"
/>
<label htmlFor="URL">URL <span className="red">*</span></label>
<input
type="text"
value={nft.url}
Expand All @@ -82,14 +86,25 @@ const MintLeapFrogNFT: React.FC = () => {
url:e.target.value
}))}
placeholder="Enter url"
className="input-field mr-2"
className="input-field mb-4"
/>
<label htmlFor="Recipient address">Recipient address <span className="red">*</span></label>
<input
type="text"
value={nft.address}
onChange={(e) => setNFT((prevState) => ({
...prevState,
address:e.target.value
}))}
placeholder="Enter recipient address"
className="input-field mb-4"
/>
<button
onClick={handleSubmit}
className={`${clsx('button', { 'button-disabled': loading })} p-3 min-w-28`}
disabled={loading|| coins==="Congratulations! You have successfully completed this level!" }
disabled={loading|| coins==="Congratulations! You have successfully completed this level!" || nft.name==='' || nft.description==='' || nft.url==='' || nft.address===''}
>
{loading ? 'Loading...' : 'Submit'}
{loading ? 'Loading...' : 'Submit Challenge'}
</button>
</div>
<div className="flex items-center">
Expand Down
4 changes: 2 additions & 2 deletions docs/site/src/utils/ctf-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export const handleMintLeapFrogSubmit = async ({
const NETWORKS = {
testnet: { url: getFullnodeUrl('testnet') },
};
const NFTPackageAddress = "0x972f3cfc6a824a319485a8c7e9e8bc0ad845e1682d277c6b4d10b5c9511685d7"
const NFTPackageAddress = "0x649884331fa662235b2c06c6eb488e5327105dded1331f6b7541ef4fdbd9eeca"
const client = new IotaClient({ url: NETWORKS.testnet.url });

const message = 'Congratulations! You have successfully completed this level!';
Expand All @@ -134,7 +134,7 @@ export const handleMintLeapFrogSubmit = async ({
tx.setGasBudget(50000000);
tx.moveCall({
target: `${NFTPackageAddress}::leap_frog_nft::mint_to_sender`,
arguments: [tx.pure.vector('u8', arg0), tx.pure.vector('u8', arg1), tx.pure.vector('u8', arg2)],
arguments: [tx.pure.vector('u8', arg0), tx.pure.vector('u8', arg1), tx.pure.vector('u8', arg2), tx.pure.address(nft.address)],
});
return tx;
};
Expand Down

0 comments on commit 8a2e901

Please sign in to comment.