`import * as Token from "token";
import { Address} from "soroban-client";
const token = new Token.Contract({
contractId: Token.networks.futurenet.contractId,
networkPassphrase: "Test SDF Future Network ; October 2022",
rpcUrl: networkUrl,
});
const Web3Page = (props: Web3PageProps) => {
const [tokenName, setTokenName] = useState("");
const [tokenSymbol, setTokenSymbol] = useState("");
const [tokenAddress, setTokenAddress] = useState("");
const [balance, setBalance] = useState(0);
async function tokenDetail() {
try {
let tokenName = await token.name();
token.symbol().then(setTokenSymbol);
let publicKey = new Address(props.pubKey);
let balance = await token.balance({ id: publicKey });
let formatted_balance = Number(balance) / 100000000;
setBalance(formatted_balance);
setTokenName(tokenName);
setTokenAddress(Token.networks.futurenet.contractId);
} catch (error) {
alert(error);
console.log(error);
}
}
useEffect(() => {
tokenDetail();
});
return (
<div>
<div style={{ marginBottom: "5%" }}>
Connected Wallet Address: {props.pubKey}
</div>
<h3>Token Detail</h3>
<h4>Token Name: {tokenName}</h4>
<h4>Symbol: {tokenSymbol}</h4>
<h5>Token Contract Address: {tokenAddress}</h5>
<h3>
Balance: {balance} {tokenSymbol}
</h3>
</div>
);
};
export default Web3Page;`