#Sign a contract xdr from vanilla Js
9 messages · Page 1 of 1 (latest)
My code
const stellarServer = "https://soroban-testnet.stellar.org"
const stellarServer_1 = "https://horizon-testnet.stellar.org"
const stellarServer_2 = "https://soroban-testnet.stellar.org:44"
const daoContractId = "CCGBC2P2HEXU37JNY5RKFZLKZ4G6LMRW7TFHA6ZTRA6BRDXQCTM2VJ2Y"
@if (isset($_COOKIE['wallet']))
const walletAddress = "{{ $_COOKIE['public'] }}"
@else
const walletAddress = ""
@endif
// console.log(window)
//SET UP FUNCTION
const createDaos = async () => {
if(walletAddress != "") {
const server = new SorobanClient.Server(stellarServer);
const account = await server.getAccount(walletAddress);
const fee = 100;
const contract = new SorobanClient.Contract(daoContractId);
let _walletAdr = new SorobanClient.Address(walletAddress)
_walletAdr = _walletAdr.toScVal()
let _tokenAdr = new SorobanClient.Address("CCXHCCDBUJ34KHSFOTMY7SLPBHBRG346BTSTBBT5RJKA22LG6G7UXG6J")
_tokenAdr = _tokenAdr.toScVal()
const _name = SorobanClient.nativeToScVal("DAO")
let transaction = new SorobanClient.TransactionBuilder(account, { fee, networkPassphrase: SorobanClient.Networks.TESTNET })
.addOperation(
// An operation to call increment on the contract
contract.call("increment", _walletAdr, _tokenAdr, _name)
)
.setTimeout(30)
// Uncomment to add a memo (https://developers.stellar.org/docs/glossary/transactions/)
// .addMemo(SorobanClient.Memo.text('Hello world!'))
.build();
transaction = await server.prepareTransaction(transaction);
const xdrEnvelope = await transaction.toEnvelope().toXDR('base64');
console.log( await window.freighterApi.signTransaction('xdrEnvelope', "TESTNET"))
Operations and transactions: how they work
it should be Networks.TESTNET for the correct network passphrase
according to https://docs.freighter.app/docs/guide/usingFreighterNode#signtransaction it should be more like signTransaction(xdrEnvelope, { networkPassphrase: Networks.TESTNET }), I think?
We now have an extension installed on our machine and a library to interact with it. This library will provide you methods to send and receive data from a user's extension in your website or application.
that looks correct
I am not using nodeJs. I am using freighter in the browser
XDR Read Error: unknown ScValType member for value -1945015814
This is what freighter returns everytime
Can you share your code we will help
We been able to solve it. There is a bug with the freighter wallet