@@ -111,7 +111,7 @@ Let's start by creating a button component that we'll use throughout our applica
111111import React from " react" ;
112112
113113interface ButtonProps {
114- onClick: () => void ;
114+ onClick? : () => void ;
115115 children: React .ReactNode ;
116116 disabled? : boolean ;
117117 className? : string ;
@@ -418,7 +418,7 @@ import { rpc as StellarRpc } from "@stellar/stellar-sdk";
418418import {
419419 isConnected ,
420420 setAllowed ,
421- getPublicKey ,
421+ getAddress ,
422422 signTransaction ,
423423} from " @stellar/freighter-api" ;
424424
@@ -430,8 +430,8 @@ export default function Home() {
430430 try {
431431 const connected = await isConnected ();
432432 if (connected ) {
433- const pubKey = await getPublicKey ();
434- setPublicKey (pubKey );
433+ const pubKey = await getAddress ();
434+ setPublicKey (pubKey . address );
435435 }
436436 } catch (error ) {
437437 console .error (" Error checking Freighter connection:" , error );
@@ -444,8 +444,8 @@ export default function Home() {
444444 const handleConnectWallet = async () => {
445445 try {
446446 await setAllowed ();
447- const pubKey = await getPublicKey ();
448- setPublicKey (pubKey );
447+ const pubKey = await getAddress ();
448+ setPublicKey (pubKey . address );
449449 } catch (error ) {
450450 console .error (" Error connecting to Freighter:" , error );
451451 }
@@ -482,7 +482,7 @@ export default function Home() {
482482
483483 const transactionResult = await server .sendTransaction (
484484 StellarSdk .TransactionBuilder .fromXDR (
485- signedTransaction ,
485+ signedTransaction . signedTxXdr ,
486486 StellarSdk .Networks .TESTNET ,
487487 ),
488488 );
@@ -520,7 +520,7 @@ In the updated `app/page` component, we added a `useEffect` hook to check if the
520520
521521The ` handleSendPayment ` function now interacts with the Stellar network to send a payment. It retrieves the source account details, creates a payment transaction, signs the transaction using the Freighter wallet, and sends the transaction to the Stellar network. If the transaction is successful, it displays an alert to the user.
522522
523- Notice how we imported the ` isConnected ` , ` setAllowed ` , ` getPublicKey ` , and ` signTransaction ` functions from the ` @stellar/freighter-api ` library. These functions are used to interact with the Freighter wallet extension and sign transactions securely.
523+ Notice how we imported the ` isConnected ` , ` setAllowed ` , ` getAddress ` , and ` signTransaction ` functions from the ` @stellar/freighter-api ` library. These functions are used to interact with the Freighter wallet extension and sign transactions securely.
524524
525525:::tip
526526
@@ -550,15 +550,15 @@ import {
550550} from " @stellar/stellar-sdk" ;
551551import React , { useEffect , useState } from " react" ;
552552import {
553- getPublicKey ,
553+ getAddress ,
554554 isConnected ,
555555 signTransaction ,
556556} from " @stellar/freighter-api" ;
557557
558558import { ConnectButton } from " @/components/ConnectButton" ;
559559
560560// Replace with your actual contract ID and network details
561- const CONTRACT_ID = " CC6MWZMG2JPQEENRL7XVICAY5RNMHJ2OORMUHXKRDID6MNGXSSOJZLLF " ;
561+ const CONTRACT_ID = " CBWNXQRGC7WFYGDXUANDAZSRF2E5NPPA3NP6UZSPHYBVU3K46PSNWQOO " ;
562562const NETWORK_PASSPHRASE = Networks .TESTNET ;
563563const SOROBAN_URL = " https://soroban-testnet.stellar.org:443" ;
564564
@@ -567,12 +567,14 @@ export default function CounterPage() {
567567 const [count, setCount] = useState <number | null >(null );
568568 const [loading, setLoading] = useState (false );
569569
570+ const server = new StellarRpc .Server (SOROBAN_URL );
571+
570572 useEffect (() => {
571573 const checkWallet = async () => {
572574 const connected = await isConnected ();
573575 if (connected ) {
574- const pubKey = await getPublicKey ();
575- setPublicKey (pubKey );
576+ const pubKey = await getAddress ();
577+ setPublicKey (pubKey . address );
576578 }
577579 };
578580
@@ -588,7 +590,6 @@ export default function CounterPage() {
588590 setLoading (true );
589591
590592 try {
591- const server = new StellarRpc .Server (SOROBAN_URL );
592593 const account = await server .getAccount (publicKey );
593594
594595 const contract = new Contract (CONTRACT_ID );
@@ -642,7 +643,7 @@ export default function CounterPage() {
642643
643644 // Extract the new count from the transaction result
644645 const returnValue = getResponse .resultMetaXdr
645- .v3 ()
646+ .v4 ()
646647 .sorobanMeta ()
647648 ?.returnValue ();
648649 if (returnValue ) {
@@ -660,7 +661,7 @@ export default function CounterPage() {
660661 };
661662
662663 return (
663- < div className = " max-w-md mx-auto mt-10" >
664+ < div className = " max-w-md mx-auto mt-10 text-black " >
664665 < h1 className = " text-2xl font-bold mb-4" >
665666 Stellar Smart Contract Counter
666667 < / h1 >
@@ -752,8 +753,8 @@ useEffect(() => {
752753 const checkWallet = async () => {
753754 const connected = await isConnected ();
754755 if (connected ) {
755- const pubKey = await getPublicKey ();
756- setPublicKey (pubKey );
756+ const pubKey = await getAddress ();
757+ setPublicKey (pubKey . address );
757758 }
758759 };
759760 checkWallet ();
@@ -764,6 +765,7 @@ const getInitialCount = async () => {
764765 try {
765766 const topic1 = xdr .ScVal .scvSymbol (" COUNTER" ).toXDR (" base64" );
766767 const topic2 = xdr .ScVal .scvSymbol (" increment" ).toXDR (" base64" );
768+
767769 const latestLedger = await server .getLatestLedger ();
768770 const events = await server .getEvents ({
769771 startLedger: latestLedger .sequence - 2000 ,
0 commit comments