Validate Space Address
To validate the address of a member, you must call validateAddress
on dataset(Dataset.MEMBER)
. validateAddress
takes an object of type Build5Request
<
AddressValidationRequest
>
as parameter.
const response = await https(origin)
.project(SoonaverseApiKey[Build5.TEST])
.dataset(Dataset.SPACE)
.validateAddress({
address: address.bech32,
signature: signature.signature,
publicKey: {
hex: signature.publicKey,
network: Network.RMS,
},
body: {
network: 'rms',
},
});
validateAddress
returns an oject of type Transaction
.
Validated Address
To validate your address you will have to send the requested amount to the target address. This will validate the address you are sending from.
Full How-To Code
import { Dataset, Network } from '@build-5/interfaces';
import { Build5, SoonaverseApiKey, https } from '@build-5/sdk';
import { address } from '../utils/secret';
import { walletSign } from '../utils/utils';
async function main() {
const origin = Build5.TEST;
try {
const member = await https(origin)
.project(SoonaverseApiKey[Build5.TEST])
.dataset(Dataset.MEMBER)
.id(address.bech32)
.get();
const name = Math.random().toString().split('.')[1];
const signature = await walletSign(member.uid, address);
const response = await https(origin)
.project(SoonaverseApiKey[Build5.TEST])
.dataset(Dataset.MEMBER)
.update({
address: address.bech32,
signature: signature.signature,
publicKey: {
hex: signature.publicKey,
network: Network.RMS,
},
body: {
name: name + '_fun',
},
});
console.log('Member updated: ', response);
} catch (error) {
console.error('Error: ', error);
}
}
main().then(() => process.exit());