Estoy compilando todos los códigos que se puedan obtener desde HTML, con la autenticacion de Web3Auth. Quiero obtener balances para cada cryptomoneda, pantalla con los NFT’s comprados y hacer transacciones desde HTML JavaScript. Para traducirlo a código C# dentro de un WebGl de Unity
I am compiling all the codes that can be obtained from HTML, with the authentication of web3auth. I want to obtain balances for each cryptomoneda, screen with the bought NFT’s and make transactions from HTML JavaScript. To translate it into c code within a unity webgl
I have find a new form to do WebGl works with Web3Auth. Is really complicated, but I let here the HTML I use in Body of HTML, tis is all I have, but I even need Know how get a balance of one specific token, and the list of NFT’s in the wallet. Some one could help me? @cryptokid
<body>
<script src="https://cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/buffer@6"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/web3.min.js"></script>
<script src="https://unpkg.com/@web3auth/web3auth@latest/dist/web3auth.umd.min.js"></script>
<script>
// connect to Moralis server
const serverUrl = "https://rzruathwx1qr.usemoralis.com:2053/server";
const appId = "LqnOAN1cjjvXfaDvY0gp263Gl3jQUNDHxIgCJIyj";
Moralis.start({ serverUrl, appId });
async function init () { Login (); }
init();
$("#login").click(async function (event) {Login();});
async function Login () {
let user = Moralis.User.current();
if (!user) {
user = await Moralis.authenticate({
provider: "web3Auth",
clientId: "BGofcxX8J7KGSZPHhdCN4r6Wc8QZAX52hReZf40BK9_mqm-LHtvJQmydZEjR34J2Gzv_kNoKtTMU3g04phTJqnM",
theme: "dark",
})
}
console.log("logged in user:", user);
Connected ();
}
async function Connected (){
unityInstance.SendMessage("NecesarioEscenas", "Connect" );
GetAddress();
GetBalance();
GetUsername();
SetUsername();
}
$("#get-user-info").click(async function (event) { GetUsername();});
async function GetUsername( ){
try {
let user = Moralis.User.current();
const accounts = await user.get("username")
console.log(accounts);
unityInstance.SendMessage("NecesarioEscenas", "PonerUsername", accounts );
} catch (error) {
console.error(error.message);
}
}
async function SetUsername(){
try {
let user = Moralis.User.current();
let confirmacion = confirm("Tu nombre de usuario es " + await user.get("username")+ " \n ¿Quieres cambiarlo?")
if(confirmacion){
let newusername = prompt('Ingresa un nuevo nombre de usuario', '');
let valorUnico = Math.floor(Math.random() * 1000);
newusername = newusername+ "_00"+valorUnico.toString();
user.set("username", newusername)
await user.save()
GetUsername();
}
} catch (error) {
console.error(error.message);
}
}
async function SetScore(score ){
try {
let user = Moralis.User.current();
user.put("Score", score)
await user.save()
} catch (error) {
console.error(error.message);
}
}
$("#logout").click(async function (event) {Logout();})
async function Logout() {
await Moralis.User.logOut();
console.log("logged out");
unityInstance.SendMessage("NecesarioEscenas", "Disconnect" );
}
</script>
</body>
Know how get a balance of one specific token
You can use getTokenBalances with token_addresses params to filter the results for a specific token.
the list of NFT’s in the wallet
You can use getNFTs.
Excellent!! Thanks! do you know how could I do Rinkeby Here?
getNFTs({ chain: "goerli" });
It would be chain: "rinkeby"
.
Just note that rinkeby support for the Moralis API will be dropped by October 12th as rinkeby is shutting down.
Sorry, dont knew it, I do my job in eth mainet, and I test in rinkeby, do you know about any other option?
goerli
and mumbai
are common choices for testnets.
can you please explain a little more how to use web3auth in unity webgl?
Im not use web3auth in unity. I use web3auth on site and send token to unity for check authen token from unity
actually i am also doing the same, how are you verifying token from unity?
check in db table session and expire date