2

I defined the ink! method and struct like this:

#[derive(SpreadAllocate, PackedLayout, SpreadLayout, Clone, Decode, Encode)]
#[cfg_attr(feature = "std", derive(Debug, scale_info::TypeInfo, StorageLayout))]
pub struct ShowTest{
    test_id: u8,
}

//...

#[ink(message)]
pub fn show_test_add(&mut self, v: ShowTest) {
}

After I deployed the contract to the local contract-test chain, I found the method name show_test_add became showTestAdd and field name test_id became testId.

And it was the same when I used polkadot api in JS, I don't know why.

enter image description here

1 Answer 1

7

Polkadot.js transforms contract message names to camelCase for consistency across its packages and alignment with JavaScript common practice.

https://polkadot.js.org/docs/api-contract/FAQ#why-is-there-a-snake_case-vs-camelcase-difference

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.