-
Originally from Stack Overflow. I made an app that returns user assets from the Aptos blockchain. In the app, I have a form for the user's address. My goal is to validate that address using RegExp or something like that. |
Beta Was this translation helpful? Give feedback.
Answered by
banool
Mar 7, 2024
Replies: 1 comment
-
You can do that with the TS SDK like this: import { AccountAddress } from "../../src";
function myFunction {
let addr = "0x1";
// Get an actual AccountAddress object.
let accountAddress = AccountAddress.from(addr);
// Just check if the account address is valid.
let result = AccountAddress.isValid(addr);
let valid = result.valid;
} You can learn more about AccountAddress here: https://aptos-labs.github.io/aptos-ts-sdk/@aptos-labs/ts-sdk-1.9.1/classes/AccountAddress.html. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
banool
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can do that with the TS SDK like this:
You can learn more about AccountAddress here: https://aptos-labs.github.io/aptos-ts-sdk/@aptos-labs/ts-sdk-1.9.1/classes/AccountAddress.html.