GitHub - syronlabs/stellar-mcp: A Stellar MCP to interact with Horizon API and Soroban (original) (raw)
const result = await soroban.retrieveContractMethods({ contractAddress: 'CACLOQNDBVG2Q7VRQGOKC4THZ34FHW2PUYQQOAVBSLJEV6VHEF3ZCIPO', });
// Example response: [ { type: 'text', text: '🚀 Retrieving contract methods for address: CACLOQNDBVG2Q7VRQGOKC4THZ34FHW2PUYQQOAVBSLJEV6VHEF3ZCIPO', }, { type: 'text', text: 'Interface retrieved successfully', }, { type: 'text', text: 'Contract Interface', }, { type: 'text', text: JSON.stringify( { name: 'Contract', methods: [ { name: 'set_admin', parameters: [{ name: 'admin', type: 'Address' }], returnType: '()', }, { name: 'get_admin', parameters: [], returnType: 'Address', }, { name: 'method_with_args', parameters: [ { name: 'arg1', type: 'u32' }, { name: 'arg2', type: 'u32' }, ], returnType: '(u32, u32)', }, { name: 'handle_integers', parameters: [ { name: 'i32_val', type: 'i32' }, { name: 'i64_val', type: 'i64' }, { name: 'i128_val', type: 'i128' }, { name: 'i256_val', type: 'I256' }, { name: 'u32_val', type: 'u32' }, { name: 'u64_val', type: 'u64' }, { name: 'u128_val', type: 'u128' }, { name: 'u256_val', type: 'U256' }, ], returnType: '(i32, u32)', }, { name: 'handle_strings', parameters: [ { name: 'str_val', type: 'String' }, { name: 'bytes_val', type: 'Bytes' }, { name: 'bytes_n_val', type: 'BytesN<32>' }, ], returnType: 'String', }, { name: 'handle_collections', parameters: [ { name: 'map', type: 'Map<String, u32>' }, { name: 'vec', type: 'Vec' }, ], returnType: '(Map<String, u32>, Vec)', }, { name: 'handle_custom_types', parameters: [ { name: 'data', type: 'Data' }, { name: 'complex_data', type: 'ComplexData' }, ], returnType: '(Data, ComplexData)', }, { name: 'handle_optionals', parameters: [ { name: 'maybe_u32', type: 'Option' }, { name: 'maybe_address', type: 'Option
' }, ], returnType: 'OptionalData', }, { name: 'get_admin_from_storage', parameters: [], returnType: 'Result<Address, ContractError>', }, ], structs: [ { name: 'Data', fields: [ { name: 'admin', type: 'Address', visibility: 'pub' }, { name: 'counter', type: 'u32', visibility: 'pub' }, { name: 'message', type: 'String', visibility: 'pub' }, ], }, { name: 'ComplexData', fields: [ { name: 'admin', type: 'Address', visibility: 'pub' }, { name: 'data', type: 'Data', visibility: 'pub' }, { name: 'bytes', type: 'Bytes', visibility: 'pub' }, { name: 'bytes_n', type: 'BytesN<32>', visibility: 'pub' }, { name: 'duration', type: 'Duration', visibility: 'pub' }, { name: 'map', type: 'Map<String, u32>', visibility: 'pub' }, { name: 'symbol', type: 'Symbol', visibility: 'pub' }, { name: 'timepoint', type: 'Timepoint', visibility: 'pub' }, { name: 'vec', type: 'Vec', visibility: 'pub' }, ], }, { name: 'OptionalData', fields: [ { name: 'maybe_u32', type: 'Option', visibility: 'pub' }, { name: 'maybe_address', type: 'Option', visibility: 'pub', }, ], }, ], enums: [ { name: 'DataKey', variants: [ { name: 'Admin' }, { name: 'Counter' }, { name: 'Data' }, { name: 'Account', dataType: 'Address' }, { name: 'Contract', dataType: '(Address, u64)' }, ], isError: false, }, { name: 'ContractError', variants: [ { name: 'AdminNotFound', value: 1 }, { name: 'InvalidValue', value: 2 }, { name: 'OptionNotFound', value: 3 }, ], isError: true, }, ], }, null, 2, ), }, ];The parser supports various parameter and return types. Note that the env parameter is automatically filtered out from the interface as it is provided by the Soroban blockchain environment.
All contract methods in Soroban receive an env parameter that provides access to the blockchain environment. This parameter is automatically provided by the Soroban blockchain and is filtered out from the interface. For example, a method defined as: