# Deriving an evm address for a cansiter

**URL:** <https://forum.dfinity.org/t/deriving-an-evm-address-for-a-cansiter/40204>\
**Category:** Developers\
**Tags:** Functional-Programming\
**Created:** [January 17, 2025, 6:03pm UTC](https://forum.dfinity.org/t/deriving-an-evm-address-for-a-cansiter/40204 "2025-01-17T18:03:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Henry\_Suso](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/henry_suso/32/16796_2.png) [@Henry\_Suso](https://forum.dfinity.org/u/Henry_Suso)\
**Post date:** [January 17, 2025, 6:03pm UTC](https://forum.dfinity.org/t/deriving-an-evm-address-for-a-cansiter/40204/1 "2025-01-17T18:03:18Z")

</div>

I have been trying to derive an evm address (base chain) by doing something like this

/// getEvmAddress : Derive EVM address from secp256k1 pubkey  
public shared func getEvmAddress() : async Text {  
let pkResult = await getEcdsaPublicKey();  
switch (pkResult) {  
case (#err(e)) {  
let msg = switch(e) {  
case (#GenericError(text)) { text };  
case (#InsufficientFunds) { “Insufficient funds” };  
case (#InvalidSignature) { “Invalid signature” };  
case (#NonceTooHigh) { “Nonce too high” };  
case (#NonceTooLow) { “Nonce too low” };  
case (#NotOwner) { “Not owner” };  
case (#RpcError(text)) { text };  
};  
"ERROR\_ECDSA\_PUBKEY: " # msg  
};  
case (#ok(pubKey)) {  
if (pubKey.size() \< 65) {  
“ERROR: unexpected pubKey size”  
} else {  
let raw = Array.tabulate(64, func(i) {  
Blob.toArray(pubKey)[i + 1] // skip 0x04  
});  
let sha3 = SHA3.Keccak(256);  
sha3.update(raw);  
let hash = sha3.finalize();  
let addrBytes = Array.subArray(hash, hash.size() - 20, 20);  
“0x” # Hex.encode(addrBytes)  
};  
};  
};  
}

I’m using key\_1 as I’m doing this on main net. It seem unable to get the address as it’s ERROR\_ECDSA\_PUBKEY and it cannot route to management canister and it’s supply keys. Any thoughts from the big brains here?
