I’m trying to create a very simple contract in which I want to return the user address but I’m struggling to understand the error message I receive, here is my contract:
contract;
use std::{
auth::{
AuthError,
msg_sender,
},
};
abi GetWallet {
fn get_user_wallet() -> Address;
}
impl GetWallet for Contract {
fn get_user_wallet() -> Address {
let sender: Result<Identity, AuthError> = msg_sender();
if let Identity::Address(address) = sender.unwrap() {
address
} else {
revert(1);
}
}
}
I try to call the method from a test:
#[tokio::test]
async fn can_get_user_wallet() {
let (instance, _id) = get_contract_instance().await;
let result = instance.methods().get_user_wallet().call().await.unwrap();
}
But from here I got the following error:
---- can_get_user_wallet stdout ----
thread 'can_get_user_wallet' panicked at tests/harness.rs:42:68:
called `Result::unwrap()` on an `Err` value: RevertTransactionError { reason: "InvalidMetadataIdentifier", revert_id: 0, receipts: [Call { id: 0000000000000000000000000000000000000000000000000000000000000000, to: eb8692ce06ce1cf98ef679b29700cfdeff03d19254a080dfcd891baede402887, amount: 0, asset_id: 0000000000000000000000000000000000000000000000000000000000000000, gas: 40, param1: 755406600, param2: 0, pc: 11624, is: 11624 }, Panic { id: eb8692ce06ce1cf98ef679b29700cfdeff03d19254a080dfcd891baede402887, reason: PanicInstruction { reason: InvalidMetadataIdentifier, instruction: GTF { dst: 0x10, arg: 0x14, selector: 257 } (bytes: 61 41 41 01) }, pc: 12056, is: 11624, contract_id: None }, ScriptResult { result: Panic, gas_used: 224 }] }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Am I doing something wrong? What does this error means exactly ?
If ever it helps, fuelup show result:
installed toolchains
--------------------
beta-4-x86_64-unknown-linux-gnu (default)
latest-x86_64-unknown-linux-gnu
active toolchain
----------------
beta-4-x86_64-unknown-linux-gnu (default)
forc : 0.46.1
- forc-client
- forc-deploy : 0.46.1
- forc-run : 0.46.1
- forc-crypto : not found
- forc-doc : 0.46.1
- forc-explore : 0.28.1
- forc-fmt : 0.46.1
- forc-lsp : 0.46.1
- forc-tx : 0.46.1
- forc-wallet : 0.3.0
fuel-core : 0.20.5
fuel-core-keygen : Error getting version string
fuels versions
--------------
forc : 0.45
forc-wallet : 0.45