lopo1
June 20, 2024, 4:32am
1
my code is here
let balances = wallet.get_balances().await.unwrap();
println!("balances: {:?}", balances);
let asset_id = contract_instance.methods().asset_id(sub_id).call().await.unwrap();
let asset = asset_id.value;
println!("asset {:?}",asset);
let burn = contract_instance.methods().burn(sub_id,1).with_variable_output_policy(VariableOutputPolicy::EstimateMinimum).with_tx_policies(TxPolicies::default()).call().await;
dbg!(&burn);
response is here
asset e38ca8877350a706e45d1b7905f0167529914f6955bc2f1fb2c9242101956d56
balances: {"603b0679e65e6bb3a0fdc6ab370fc2f692978c62f8f4a9ac9a240ecfe5b297b5": 1, "e38ca8877350a706e45d1b7905f0167529914f6955bc2f1fb2c9242101956d56": 1, "4925923ac3f80e8bc180c5d2a470238cbb532af91919e10257c971717f80f170": 9000000000, "f8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07": 5181897}
asset e38ca8877350a706e45d1b7905f0167529914f6955bc2f1fb2c9242101956d56
[examples/contract.rs:64:5] &burn = Err(
Transaction(
Reverted {
reason: "NotEnoughCoins",
revert_id: 18446744073709486080,
receipts: [
Call {
id: 0x0000000000000000000000000000000000000000000000000000000000000000,
to: 0x20667443791e287f39703462e179904ba106063fd7c16c5188e9a5ba9e6faa78,
amount: 0,
asset_id: 0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07,
gas: 9158,
param1: 10480,
param2: 10492,
pc: 11712,
is: 11712,
},
LogData {
id: 0x20667443791e287f39703462e179904ba106063fd7c16c5188e9a5ba9e6faa78,
ra: 0,
rb: 4237256875605624201,
ptr: 67107328,
len: 8,
digest: 0xaf5570f5a1810b7af78caf4bc70a660f0df51e42baf91d4de5b2328de0e83dfc,
pc: 28916,
is: 11712,
data: Some(0000000000000000),
},
Revert {
id: 0x20667443791e287f39703462e179904ba106063fd7c16c5188e9a5ba9e6faa78,
ra: 18446744073709486080,
pc: 28924,
is: 11712,
},
ScriptResult {
result: Revert,
gas_used: 33237,
},
],
},
),
)
naz3eh
June 21, 2024, 4:35pm
2
just want to confirm are you on the latest version of rust SDK ie 0.64.0
?
lopo1
June 24, 2024, 6:20am
3
yes,its‘s rust sdk 0.64.0
lopo1
June 25, 2024, 6:57am
4
Has anyone ever encountered this?
naz3eh
June 25, 2024, 9:03am
5
Can you please share your codebase, so that I can directly run it and reproduce it locally?
lopo1
June 26, 2024, 3:46pm
6
my test
#[warn(unused_imports)]
use fuels::{crypto::SecretKey, prelude::*, types::{Bits256,Bytes32, ContractId, Identity}};
use std::str::FromStr;
#[tokio::main]
async fn main() {
abigen!(Contract(
name = "MyContract",
abi = "out/debug/src7_token-abi.json"
));
let provider = Provider::connect("https://testnet.fuel.network/v1/graphql").await.unwrap();
let secret =
SecretKey::from_str("cc74e38f91112c34aa913592888e3a582850bfeaaa04cbb6914a746a9eb564e1")
.unwrap();
// Create the wallet
let wallet = WalletUnlocked::new_from_private_key(secret, Some(provider.clone()));
let contract_id: ContractId =
"0x20667443791e287f39703462e179904ba106063fd7c16c5188e9a5ba9e6faa78"
.parse()
.expect("Invalid ID");
let hex_str = format!("{:064x}", 1);
// 添加 '0x' 前缀
let hex_str_with_prefix = format!("0x{}", hex_str);
println!("hex_str_with_prefix {}",hex_str_with_prefix);
let sub_id = Bits256::from_hex_str(&hex_str_with_prefix).unwrap();
let contract_instance = MyContract::new(contract_id, wallet.clone());
let asset_id = contract_instance.methods().asset_id(sub_id).call().await.unwrap();
let asset = asset_id.value;
println!("asset {:?}",asset);
let form = Identity::Address(wallet.address().into());
let init = contract_instance.methods().constructor(form).call().await.unwrap();
// 将数字转换为十六进制字符串
let burn = contract_instance.methods().burn(sub_id,1).with_variable_output_policy(VariableOutputPolicy::EstimateMinimum).with_tx_policies(TxPolicies::default()).call().await;
dbg!(&burn);
}
src7_token-abi.json
lopo1
June 28, 2024, 2:28am
8
Is there a solution to my problem?
naz3eh
June 28, 2024, 5:01am
9
Hey @lopo1 , tests are passing for me Warp
lopo1
June 28, 2024, 6:14am
10
naz3eh:
Warp
You should use cargo run-- example nft_burn
lopo1
July 1, 2024, 7:08am
11
What is the cause of this, can you help me to see
naz3eh
July 2, 2024, 10:10am
12
Hey @lopo1 , i have asked the team and will keep you posted
1 Like
naz3eh
July 3, 2024, 11:32am
13
You need to include the asset that is burned in the call pararmeters:
let call_params = CallParameters::new(amount, asset_id, 1_000_000);
let burn = contract_instance
.methods()
.burn(sub_id,1)
.with_variable_output_policy(VariableOutputPolicy::EstimateMinimum)
.with_tx_policies(TxPolicies::default())
.call_params(call_params)
.call()
.await;
1 Like
lopo1
July 5, 2024, 10:30am
14
Can this be an asset that can only be burned at your own address? If you have contractual authority, can’t you burn nft at other addresses?
naz3eh
July 8, 2024, 5:44pm
15
Only the minting contract has the ability to burn as the AssetId
is the hash of the ContractId
and SubId
lopo1
July 9, 2024, 10:08am
16
If there is an nft AssetId on address A, address B has contract burn authority, can address B burn off A’s AssetId?
naz3eh
July 10, 2024, 7:13am
17
For any asset to be burned, it must be sent to or owned by the contract that minted it.
lopo1
July 10, 2024, 8:26am
18
That is, if address A does not have this nft asset, it cannot burn the asset at address B, unless address B transfers the asset back to address A, or the contract, address A has the right to burn this asset
system
Closed
July 31, 2024, 4:27am
19
This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.