when I deploy smartcontract, it send back the whole balance as soon as I deployed. is there anyone know what this issue is?
Mar 17, 2023, 10:31 PM
bounce = false ?
Mar 17, 2023, 10:34 PM
I set bounce = false😔
export async function deployTonate(via: Sender, dto: DeployTonateDto) {
// initCode
const tonateCellName = "tonate_" + dto.visibility + "_" + dto.method + ".cell";
// // retreive cell data
const tonateCell = await fetch("https://tonate.xyz/counter.cell")
.then((res) => res.arrayBuffer())
.then((arrayBuffer) => Buffer.from(arrayBuffer));
const tonateCode = Cell.fromBoc(tonateCell)[0];
// initCell
let tonate;
if (dto.visibility == "public"){
tonate = Tonate.createForDeploy(
tonateCode,
initDataPublic(
Address.parse(dto.userAddress!),
Address.parse(TONATE_TRACKER_WALLET_ADDRESS),
dto.userNumber!,
dto.title!
)
);
}
else{ // dto.visibility == "private"
tonate = Tonate.createForDeploy(
tonateCode,
initDataPrivate(
via.address!,
dto.userNumber!,
dto.title!
)
);
}
// // init client to make Open Contract
const client = new TonClient({
endpoint: await getHttpEndpoint({ network: "testnet" }),
});
const tonateContract = client.open(tonate) as OpenedContract;
tonateContract.sendDeploy(via, dto.balance!.toString());
return tonateContract.address;
}
// initCode
const tonateCellName = "tonate_" + dto.visibility + "_" + dto.method + ".cell";
// // retreive cell data
const tonateCell = await fetch("https://tonate.xyz/counter.cell")
.then((res) => res.arrayBuffer())
.then((arrayBuffer) => Buffer.from(arrayBuffer));
const tonateCode = Cell.fromBoc(tonateCell)[0];
// initCell
let tonate;
if (dto.visibility == "public"){
tonate = Tonate.createForDeploy(
tonateCode,
initDataPublic(
Address.parse(dto.userAddress!),
Address.parse(TONATE_TRACKER_WALLET_ADDRESS),
dto.userNumber!,
dto.title!
)
);
}
else{ // dto.visibility == "private"
tonate = Tonate.createForDeploy(
tonateCode,
initDataPrivate(
via.address!,
dto.userNumber!,
dto.title!
)
);
}
// // init client to make Open Contract
const client = new TonClient({
endpoint: await getHttpEndpoint({ network: "testnet" }),
});
const tonateContract = client.open(tonate) as OpenedContract
tonateContract.sendDeploy(via, dto.balance!.toString());
return tonateContract.address;
}
export default class Tonate implements Contract {
static createForDeploy(code: Cell, initData: Cell): Tonate {
const workchain = 0; // deploy to workchain 0
const address = contractAddress(workchain, { code: code, data: initData });
return new Tonate(address, { code, data: initData });
}
constructor(
readonly address: Address,
readonly init?: { code: Cell; data: Cell }
) {}
async sendDeploy(provider: ContractProvider, via: Sender, balance : string) {
await provider.internal(via, {
value: balance,
bounce: false,
});
}
}
static createForDeploy(code: Cell, initData: Cell): Tonate {
const workchain = 0; // deploy to workchain 0
const address = contractAddress(workchain, { code: code, data: initData });
return new Tonate(address, { code, data: initData });
}
constructor(
readonly address: Address,
readonly init?: { code: Cell; data: Cell }
) {}
async sendDeploy(provider: ContractProvider, via: Sender, balance : string) {
await provider.internal(via, {
value: balance,
bounce: false,
});
}
}
this is the code. for deploy...
and trx is like this https://testnet.tonscan.org/address/EQAKEWbml0UeXd0aiF-gEyNPTnxIey8gqXhTbUla5JpA2znU
*https://tonate.xyz/counter.cell => should be another link
Mar 17, 2023, 10:40 PM